Archicad C++ API
About Archicad add-on development using the C++ API.

Send JSON body in HTTP request

dushyant
Enthusiast

Hi,

I am trying to send data in JSON format in an HTTP request like this:

GS::UniString uriString = "https://domain/api";
IO::URI::URI connectionUrl(uriString);
ClientConnection clientConnection(connectionUrl);    
GS::ObjectState requestOs;
requestOs.Add("param1", "val1");
requestOs.Add("testKey2", "val2");
JSON::CreateFromObjectState(requestOs, clientConnection.BeginSend(request));
clientConnection.FinishSend();

But I am not receiving the JSON in the request on the server side (PHP).

Is this the correct way to send JSON data in an HTTP request?

Please help!  ( @Tibor Lorantfy  ? )

 

Thanks.

1 REPLY 1
BrunoValads
Contributor

You are probably missing a

clientConnection.Connect();

 right after you initialized clientConnection.