Hi
I have an issue in POST XML data to External API URL I got Error is System.ArgumentException: 'Specified value has invalid CRLF characters.
Please advice me
Thank you
Maideen
<xml><ServiceTypeID>1</ServiceTypeID><ShipperContactPerson>padhma</ShipperContactPerson><ShipperCompanyName>Jetpharma Sdn Bhd</ShipperCompanyName><ShipperPhoneNumber>03-8076 1651</ShipperPhoneNumber><OriginCountryID>1</OriginCountryID><OriginStateID>12</OriginStateID><OriginPostcode>47000</OriginPostcode><OriginCity>Bandar Puchong Jaya</OriginCity><OriginAddress>1, 11 & 13, Jalan Rajawali 2, Bandar Puchong Jaya,
47100 Puchong, Selangor</OriginAddress><RecpContactPerson>contact Person</RecpContactPerson><RecpCompanyName>Azam Bekal Enterprise</RecpCompanyName><RecpPhoneNumber>0146675956</RecpPhoneNumber><DestCountryID>1</DestCountryID><DestStateID>11</DestStateID><DestPostcode>45000</DestPostcode><DestCity>Ipoh</DestCity><DestAddress>Farmasi Azam No. 6, Jalan Cindai Jaya 1, Taman Cindai Jaya, 08000 Sungai Petani, Kedah. 08000</DestAddress><Description>small package</Description><Remarks>Remarks</Remarks><Pieces>6</Pieces><Weight>0.00</Weight><Length>1.00</Length><Width>1.00</Width><Height>1.00</Height><CODAmount>0.00</CODAmount><ReferenceNumber>SO-1298712</ReferenceNumber></xml>
Dim url = "https://gold.mxpress2u.net/gold/API.asmx"
Dim httpRequest = CType(WebRequest.Create(url), HttpWebRequest)
httpRequest.Method = "POST"
httpRequest.ContentType = "application/xml"
httpRequest.Accept = "application/xml"
Dim data = Me.txtXML.Text
httpRequest.Headers("strAPIKey") = "API Key"
httpRequest.Headers("strCustomerAccount") = "Account No"
httpRequest.Headers("intPrintFormatType") = "1"
httpRequest.Headers("strShipmentDetailsXML") = data
'' After debug the error is on "httpRequest.Headers("strShipmentDetailsXML") = data"
'' Error is System.ArgumentException: 'Specified value has invalid CRLF characters.
Dim streamWriter = New StreamWriter(httpRequest.GetRequestStream())
If True Then
streamWriter.Write(data)
End If
Dim httpResponse = CType(httpRequest.GetResponse(), HttpWebResponse)
Dim streamReader = New StreamReader(httpResponse.GetResponseStream())
If True Then
Dim result = streamReader.ReadToEnd()
End If
Console.WriteLine(httpResponse.StatusCode)