Hi Everyone!
Quite new to postman, but have managed to created a few basic APIās and looking at my first real integration project.
I have an API spitting out a response and I am trying to extract the āWorkOrderNumberā in the following response:
``<?xml version="1.0" encoding="utf-8"?>
``<feed xml:base="http://mex.viterra.com.au/MEXData/OData.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<id>http://mex.viterra.com.au/MEXData/OData.svc/WorkOrders</id>
<title type="text">WorkOrders</title>
<updated>2022-08-09T02:19:57Z</updated>
<link rel="self" title="WorkOrders" href="WorkOrders" />
<entry>
<id>http://mex.viterra.com.au/MEXData/OData.svc/WorkOrders(134031)</id>
<category term="MEXModel.WorkOrder" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="WorkOrder" href="WorkOrders(134031)" />
<title />
<updated>2022-08-09T02:19:57Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:WorkOrderID m:type="Edm.Int32">134031</d:WorkOrderID>
<d:WorkOrderNumber m:type="Edm.Int32">131401</d:WorkOrderNumber>
</m:properties>
</content>
</entry>
</feed>
``
In my Test Script I have tried the following:
``
var responseJson = xml2Json(responseBody);
var WorkOrderNumber = responseJson['feed']['entry']['content']['m:properties']['d:WorkOrderNumber'];
pm.environment.set("LastWONumber", WorkOrderNumber);
The response has what I need, the number but with additional text:
{_: ā131401ā, $: {ā¦}}
-
_: ā131401ā
-
$: {ā¦}
-
m:type: āEdm.Int32ā
I just want the number 131401 so I can pass to a variable to LastWONumber but it appears to pass all that information, not just the number.
Any hep please?