I am using TM4C1294NCPDT on EK-1294XL board. tirtos_tivac_2_14_04_3, TivaWare_C_Series-2.1.2.111, CCS_6.1.2.00015 versions.
I have taken HTTP GET example code from TI-RTOS and trying to send POST Request to local server. Following is the code snippet I have modified(code is attached in zip file):
ret = HTTPCli_sendRequest(&cli, HTTPStd_POST, REQUEST_URI, true);
if (ret < 0) {
System_printf("httpTask: send failed1111:%d", ret);
}
else{
ret = HTTPCli_sendRequestBody(&cli, POST_REQ_DATA, sizeof(POST_REQ_DATA));
if (ret < 0) {
System_printf("httpTask: send failed12222:%d", ret);
}
}
ret = HTTPCli_getResponseStatus(&cli);
if (ret != HTTPStd_OK) {
System_printf("httpTask: cannot get status:%d", ret);
}
In this code HTTPCli_getResponseStatus() is always returning 400 error. GET request is working fine and giving correct response. Reason on Server is showing that No content to map to Object due to end of input it means Request is reaching as empty to server.
Do anybody have idea what is wrong with code or how to send POST_REQ_DATA along with header parameters as JSON? Following is the request format to be sent:
POST /app/api/data/post HTTP/1.1
Host: 192.168.0.102
Authentication: Basic
Content-Type: application/json
{"ss":"true"}
Also this code is running once whenever IP is assigned. How to run this code to send POST request at regular intervals?
Thanks,
Bhavesh