Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

REST/XML instead of JSON

 Post Reply Post Reply
Author
Blanchard Edward View Drop Down
Member
Member
Avatar

Joined: 28 Jul 2016
Posts: 50
Post Options Post Options   Quote Blanchard Edward Quote  Post ReplyReply Direct Link To This Post Topic: REST/XML instead of JSON
    Posted: 12 Nov 2019 at 11:01pm

Is there any way to use XData to work with REST/XML instead of REST/JSON?

I suppose I can get away with sending the XML request with:
  Request.SetContent(TEncoding.UTF8.GetBytes(MyXMLDataVar));

But if the response is XML, how would I effectively respond when  something like this is returned :


<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_IF72_ASN_RES xmlns:ns0="xxxx">
<ShipmentID/>
<Status>
<Code>200</Code>
<Text>Succes.</Text>
<ReferenceID>Header</ReferenceID>
</Status>
</ns0:MT_IF72_ASN_RES>


That is, will  StatusCodel be parsed correctly to be able to use

 Response := Client.Send(Request);
    if Response.StatusCode = 200 then


Some of the returned error codes are IID, 11, IQT... (not the standard html error codes)

eg

<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_IF72_ASN_RES xmlns:ns0="xxxx">
<ShipmentID/>
<Status>
<Code>IID</Code>
<Text>Missing shipment ID</Text>
<ReferenceID>Header</ReferenceID>
</Status>
</ns0:MT_IF72_ASN_RES>

TIA,
EdB
Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2541
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 20 Nov 2019 at 9:39pm
The status code should be returned as HTTP status code, regardless if the content is JSON or XML.
If your status code is inside the XML, that's specific format and the client should parse the XML to get the status code in the tag specified by your application (in this case, <Code> tag).
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down