Hello everyone
i am new in hubsport . and i am try to call product api for insert data. But every time i call the api i am getting error like
{“status”:“error”,“message”:“Invalid input JSON on line 1, column 1: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token”,“correlationId”:“b8c01b31-73a1-4885-8ee8-6266d49a48c4”,“requestId”:“a60e40b17d0768d626985e20e7ef5cbd”}
and my code like
int Retval = 0;
StringBuilder SB = new StringBuilder();
var security = SecurityInfoHubSpot.Instance;
List<HSProduct> products = new List<HSProduct>();
var stringPayload = JsonConvert.SerializeObject(model);
SB.Append("[{\"name\": \"name\",\"value\": \"" + model.name + "\"},");
SB.Append("{\"name\": \"description\",\"value\": \"" + model.description.Replace("\"", "\\\"") + "\"},");
SB.Append("{\"name\": \"price\",\"value\": \"" + model.price + "\"},");
SB.Append("{\"name\": \"recurringbillingfrequency\",\"value\": \"quarterly\"}");
SB.Append("]");
string baseURL = Helper.HubSpotBaseUrl + resourcePath ;
string reqParam = String.Format("?hapikey={0}", security.HAPIKey);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls |
SecurityProtocolType.Tls11 |
SecurityProtocolType.Tls12;
ServicePointManager.MaxServicePointIdleTime = 1000;
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Clear();
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
try
{
var response = await client.PostAsJsonAsync(baseURL + reqParam, model);
if (response.IsSuccessStatusCode && response.StatusCode != HttpStatusCode.NoContent)
{
Retval = 1;
}
else
{
var errtext = response.Content.ReadAsStringAsync();
}
}
catch (Exception ex)
{
throw;
}
}
return await Task.FromResult(Retval);
}
and my json is
[{“name”: “name”,“value”: “[Sample] 1 L Le Parfait Jar”},{“name”: “description”,“value”: "
When removes for a thorough cleaning. May be frozen - just be sure to leave enough room for expansion.
"},{“name”: “price”,“value”: “9.9500”},{“name”: “recurringbillingfrequency”,“value”: “quarterly”}]
please help me