public void sendFiscal(str _json, CustInvoiceJour _custInvoiceJour) { str UserAuthToken = 'Authorization'; str apiKey = 'X-Api-Key'; str scId = 'X-SdcId'; CustParameters custParameters = CustParameters::find(); str apiURL = custParameters.AXPApiURL; System.Net.HttpWebRequest request; System.Net.HttpWebResponse response; CLRObject clrObj; System.Exception ex; System.IO.StreamWriter streamWriter; System.Net.WebHeaderCollection httpHeader; System.IO.Stream responseStream; System.IO.StreamReader reader; System.ArgumentException argEx; System.Net.WebException webException; str serviceResponse; custInvoiceJour custInvoiceJour; List listData = new List(Types::Class); ListEnumerator listEnumerator; try { new InteropPermission(InteropKind::ClrInterop).assert(); httpHeader = new System.Net.WebHeaderCollection(); httpHeader.Add(apiKey, custParameters.AXPApiKey); httpHeader.Add(scId,custParameters.AXPSdcId); clrObj = System.Net.WebRequest::Create(apiURL); request = clrObj; request.set_Headers(httpHeader); request.Method = 'POST'; request.ContentType = 'application/json'; streamWriter = new System.IO.StreamWriter(request.GetRequestStream()); streamWriter.Write(_json); streamWriter.Flush(); streamWriter.Close(); response = request.GetResponse(); responseStream = response.GetResponseStream(); reader = new System.IO.StreamReader(responseStream); serviceResponse = reader.ReadToEnd(); if (response.StatusDescription == 'OK') { info( strFmt("%1",serviceResponse)); headerResponse = FormJSONSerializer::deserializeObject(classNum(),serviceResponse); info( strFmt("%1",headerResponse.parmInternalData() )); } else { throw error("Something went wrong"); } } catch (webException) { // Handle WebException for error response if (webException.get_Response() != null) { System.Net.HttpWebResponse httpWebResponse; Notes responseString; System.IO.Stream stream; System.IO.StreamReader streamReader; // Get error response stream httpWebResponse = webException.get_Response() as System.Net.HttpWebResponse; stream = httpWebResponse.GetResponseStream(); streamReader = new System.IO.StreamReader(stream); responseString = streamReader.ReadToEnd(); // Log the error response body (usually in JSON format) error(strFmt("Error Response (JSON): %1", responseString)); // Close resources streamReader.Close(); stream.Close(); httpWebResponse.Close(); } else { // Log the exception message if no response error(strFmt("WebException occurred: %1", webException.get_Message())); } } catch (Exception::CLRError) { ex = CLRInterop::getLastException().GetBaseException(); throw error(ex.get_Message()); } catch (ex) { ex = CLRInterop::getLastException().GetBaseException(); throw error(ex.get_Message()); } catch { error("Checking!"); } }
response = request.GetResponse();
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 Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
CA Neeraj Kumar 1,771
André Arnaud de Cal... 806 Super User 2025 Season 2
Sohaib Cheema 542 User Group Leader