Hi, I am experiencing a weird issue that I cannot reproduce with Postman (it works there).
Use case
I have a minimal setup (simplified) following the docs (Search the CRM - HubSpot docs) to pull off a simple search (unfiltered, unsorted) with an empty JSON body and the System.Net.Http.HttpClient. This is the code:
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "MY API TOKEN");
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.hubapi.com/crm/v3/objects/contacts/search");
request.Content = JsonContent.Create("{}");
var response = httpClient.Send(request);
var responseBody = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
Problem
I am receiving this error all the time:
{"status":"error","message":"Invalid input JSON on line 1, column 1: Cannot construct instance of com.hubspot.inbounddb.publicobject.core.v3.search.PublicObjectSearchRequest$Json (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('{}')","correlationId":"8d449ee5-df7f-44f6-93ab-131f255826ee"}
I have tried various things with the HttpClient, but all ways lead back to this error. I cannot reproduce this error with Postman, it works perfectly there.
Help is much appreciated!