This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3220: HTTP post error 400 in CC3220

Part Number: CC3220


Hi I am trying to HTTP post in HTTP get application of SDK demo's and getting the error code 400. Please find below info and help me to resolve

////////////////////////////////////////////////////////////////////////////////////////////


int16_t ret = 0;

#define HOSTNAME "http://xxx.com"


#define REQUEST_POST_URI "/xxxx"

#define con_type   "application/json"

#define builtBuff  "{\"Temperature\":25,\"Humidity\":85,\"Celsius\":25,\"Farenheit\":78,\"MacId\":\"50:F1:4A:61:54:30\"}"

HTTPClient_Handle httpClientHandle;
int16_t statusCode;
httpClientHandle = HTTPClient_create(&statusCode,0);
if(statusCode < 0)
{
printError("httpTask: creation of http client handle failed",
statusCode);
}

ret =HTTPClient_setHeader(httpClientHandle, HTTPClient_HFIELD_REQ_CONTENT_TYPE, con_type, strlen(con_type), HTTPClient_HFIELD_PERSISTENT);

if(ret < 0)
{
printError("httpTask: setting request header failed", ret);
}

ret = HTTPClient_connect(httpClientHandle,HOSTNAME,0,0);
if(ret < 0)
{
printError("httpTask: connect failed", ret);
}

 

ret  = HTTPClient_sendRequest(httpClientHandle, HTTP_METHOD_POST, REQUEST_POST_URI, builtBuff, strlen(builtBuff), 0);

Display_printf(display, 0, 0, "post ret = %d \n", ret);

////////////////////////////////////////////////////////////////////////

Result:

post ret = 400

////////////////////////////////////

The same URI and Data is returning true in Postman,

Can I know what is wrong in my code?

Thank you