Notifications
Announcements
No record found.
internal final class APIClientCallRunnableClass { public static void main(Args _args) { APIClientCallRunnableClass::APICallHttpWebRequest(); } public static void APICallHttpWebRequest() { System.Net.HttpWebRequest request; System.IO.Stream stream; System.Exception sysEx; System.Net.WebException webEx; str apiUrl, apimSubscriptionKey, xClientId, mimeType, responseBody; apiUrl = 'https://3rd-party-application-api-url'; apimSubscriptionKey = 'my-subscription-key'; xClientId = 'my-client-id'; mimeType = 'application/json'; request = System.Net.WebRequest::Create(apiUrl) as System.Net.HttpWebRequest; request.Method = 'PUT'; request.ContentType = 'application/json'; // Set the request headers System.Net.WebHeaderCollection headerCollection = request.Headers; headerCollection.Set('Ocp-Apim-Subscription-Key', apimSubscriptionKey); headerCollection.Set('X-Client-Id', xClientId); headerCollection.Set('name', mimeType); var utf8 = System.Text.Encoding::get_UTF8(); // Set the request body var byteArrayPayload = utf8.GetBytes("{\"accountCode\":\"999991\",\"accountName\":\"999991 ADDED/UPDATED AGAIN\",\"entityCode\":\"USMF\",\"entityName\":\"Contoso Entertainment System USA\",\"id\":9739}"); try { // send out the payload using(System.IO.Stream dataStream = request.GetRequestStream()) { dataStream.Write(byteArrayPayload, 0, byteArrayPayload.Length); } // request.GetResponse() may already result in an error if the request was e.g. a Bad Request(Status Code 400). This should be handled upstream via our global error handling. using(System.Net.HttpWebResponse response = request.GetResponse() as System.Net.HttpWebResponse) { stream = response.GetResponseStream(); System.IO.StreamReader reader = new System.IO.StreamReader(stream); responseBody = reader.ReadToEnd(); } } catch (webEx) { Error(strFmt('An error occured while updating record: %1', webEx.Message)); } catch (sysEx) { Error(strFmt("An error occured while updating record: %1", sysEx.Message)); } } }
request.Method = 'PUT';
var data = JsonSerializer.Deserialize<JsonNode>(response.Content!)!;
System.Net.WebResponse response = webEx.Response(); Encoding encoding = System.Text.Encoding::UTF8; using (var reader = new System.IO.StreamReader(response.GetResponseStream(), encoding)) { str responseText = reader.ReadToEnd(); }
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
André Arnaud de Cal... 449 Super User 2025 Season 2
Martin Dráb 422 Most Valuable Professional
BillurSamdancioglu 239 Most Valuable Professional