APIs & Integrations

hpolice
Participant

Asynchronus calls for search contacts api are not working

Asynchronus calls for search contacts api are not working. I am using asynchronus call, below is the code snippet. After exucuting the ".PostAsync" line process is stopping. Please suggest by seeing the below code snippet is really API support the async??

 

var client = new RestClient("https://api.hubapi.com");
var request = new RestRequest("crm/v3/objects/contacts/search", Method.Post);
request.AddHeader("accept", "application/json");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", $"Bearer {_token}");
var body = JsonConvert.SerializeObject(contactSearchRequest);
request.AddParameter("application/json", body, ParameterType.RequestBody);
var response = await client.PostAsync(request);

0 Upvotes
3 Replies 3
SCohan
Member

Asynchronus calls for search contacts api are not working

Are you using the nuGet package v110.2.0 for RestSharp for C#?  I cannot use request.AddHeader and I

am getting frustraited.  Any feedback is appreciated. Thank you.

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Asynchronus calls for search contacts api are not working

Hey, @hpolice 👋 That's a good question. The documentation doesn't call this out as possible, so I do wonder. One question for you — have you tried wrapping your code in a try-catch block to see if any exceptions are being thrown?

 

Thanks! — Jaycee


HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates.
Learn More.


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !
0 Upvotes
hpolice
Participant

Asynchronus calls for search contacts api are not working

Hey @Jaycee_Lewis,

I have added try catch blocks, but no exeption found. It simply stoped my console application after execution of "var response = await client.PostAsync(request)" line;

 

PREVIEW
 
 
 
0 Upvotes