'I can't send a JSON from a TCP client hosted on the PIC32MZ microcontroller

I'm working with the PIC32MZ2048EFM100, with Harmony 3 and XC32 v 4.00.

I've gotten Harmony 3's example called tcpip_tcp_client to work correctly on my hardware.

I'm now modifying the project to send a query of type POST.

The original code that tries to communicate with a remote http server is like this and it works without problems:

sprintf(buffer, "GET /%s HTTP/1.1\r\n" "Host: %s\r\n" "Connection: close\r\n\r\n", appethData.path ? appethData.path : "null" ,appethData.host);

And I have modified it as follows:

sprintf(buffer, "POST /%s HTTP/1.1\r\n" 
"Host: %s\r\n"
"Connection: close\r\n\r\n"
"Content-type: application/json\r\n"
"Content-length: %d\r\n\r\n"
"%s", appethData.path ? appethData.path : "null" ,appethData.host,strlen(My_JSON),My_JSON);

But the server tells me the following: enter image description here

As I understand this problem (411) happens when Content-Length is not used,

But is not the case. If I print buffer I get this, where you can see that Content-length has a value of 69

"buffer is ...

=====================

POST /EXO.Service/DPDV/Ok HTTP/1.1
Host: 84.105.111.79
Connection: close

Content-type: application/json
Content-length: 69

{"Type":1,"Uid":"123456789","Port":6777,"ConnectionType":0}

====================="

I'm not a networking expert, so I have no idea what I can do.

Any suggestion or comment is welcome



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source