(C#) Transition from Http.PostJson3 to Http.HttpJson
Provides instructions for replacing deprecated PostJson3 method calls with HttpJson. Note: This example requires Chilkat v11.0.0 or greater.
Chilkat.Http http = new Chilkat.Http();
string url = "https://example.com/something";
string contentType = "application/json";
Chilkat.JsonObject json = new Chilkat.JsonObject();
json.LoadFile("C:/temp/requestBody.json");
// ------------------------------------------------------------------------
// The PostJson3 method is deprecated:
Chilkat.HttpResponse responseObj = http.PostJson3(url,contentType,json);
if (http.LastMethodSuccess == false) {
Debug.WriteLine(http.LastErrorText);
return;
}
// ...
// ...
// ------------------------------------------------------------------------
// Do the equivalent using HttpJson.
// Your application creates a new, empty HttpResponse object which is passed
// in the last argument and filled upon success.
Chilkat.HttpResponse responseOut = new Chilkat.HttpResponse();
bool success = http.HttpJson("POST",url,json,contentType,responseOut);
if (success == false) {
Debug.WriteLine(http.LastErrorText);
return;
}
|