(C#) Transition from Http.PostJson2 to Http.HttpStr
Provides instructions for replacing deprecated PostJson2 method calls with HttpStr. 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";
string jsonText = "{ ... }";
// ------------------------------------------------------------------------
// The PostJson2 method is deprecated:
Chilkat.HttpResponse responseObj = http.PostJson2(url,contentType,jsonText);
if (http.LastMethodSuccess == false) {
Debug.WriteLine(http.LastErrorText);
return;
}
// ...
// ...
// ------------------------------------------------------------------------
// Do the equivalent using HttpStr.
// 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.HttpStr("POST",url,jsonText,"utf-8",contentType,responseOut);
if (success == false) {
Debug.WriteLine(http.LastErrorText);
return;
}
|