Hello. I have a question.
I want to post json. It contains user information. I want to read the returned Json data.
example url : "api.abc.com/getlist/"
jsoninput = {
"MERCHANT":"merchid",
"MERCHANT_KEY":"merchkey",
"START_DATE":"2022-01-01",
"END_DATE":"2022-02-02"
}
My Code :
ServerAdress = "api.abc.com";
Resource = "getlist";
ssl1 = new OpenSSLSecureConnection(Undefined, Undefined);
HTTP = New HTTPConnection(ServerAdress,443,,,,10,ssl1);
HTTPRequest = New HTTPRequest("getlist");
HTTPRequest.Headers.Insert("Authorization", jsoninput);
HTTPRequest.Headers.Insert("Accept", "application/json");
HTTPRequest.Headers.Insert("Content-Type","application/x-www-form-urlencoded");
HTTPRequest.Headers.Insert("Accept-Language", "en_US");
HTTPRequest.Headers.Insert("Cache-Control", "no-cache");
HTTPRequest.SetBodyFromString("grant_type=client_credentials");
Connection = New HTTPConnection("api.abc.com",,,,,10,New OpenSSLSecureConnection);
JSONReader = New JSONReader;
Try
HTTPAnswer = Connection.Post(HTTPRequest); // post Request
JSONReader.SetString(HTTPAnswer.GetBodyAsString());
Data = ReadJSON(JSONReader, False);
message(Data);
Except
ErrorText = "Sending " + ErrorDescription();
message(ErrorText);
EndTry;
The 1C:Enterprise developers forum