Nested Json - Extract Data Policy - apigee

I am having trouble using the "extract data" policy for larger, nested json results. how would I write this in the apigee "extract data" policy? In particular, I'm interessted in the npi, last name, first name and business address fields.
Thanks.
{
"meta": {
"rowCount": 1
},
"result": [
{
"npi": 1671836487,
"type": "individual",
"last_name": "HUTTER",
"first_name": "JOHN",
"name_prefix": "MR.",
"credential": "MD",
"business_address": {
"address_line": "1MAINSTREET",
"city": "HARTFORD",
"state": "CT",
"zip": "06106",
"country_code": "US",
"phone": "8605551212",
"fax": "8605551212"
},
"practice_address": {
"address_line": "1MAINST",
"city": "HARTFORD",
"state": "CT",
"zip": "06106",
"country_code": "US",
"phone": "8605551212",
"fax": "8605551212"
},
"enumeration_date": "2013-04-03T00: 00: 00.000Z",
"last_update_date": "2013-04-03T00: 00: 00.000Z",
"gender": "male",
"provider_details": [
{
"healthcare_taxonomy_code": "101Y00000X",
"license_number": "002295",
"taxonomy_switch": "yes"
}
],
"sole_proprietor": "no"
}
]
}

Make sure your content-type header is set to application/json so the JSONPath option in the ExtractVariable policy works.
Here's a sample policy to extract the above (verified in my own system):
<ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-Variables-1">
<DisplayName>Extract Variables 1</DisplayName>
<FaultRules/>
<Properties/>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<JSONPayload>
<Variable name="result">
<JSONPath>$.result</JSONPath>
</Variable>
<Variable name="npi">
<JSONPath>$.result[0].npi</JSONPath>
</Variable>
<Variable name="last_name">
<JSONPath>$.result[0].last_name</JSONPath>
</Variable>
<Variable name="first_name">
<JSONPath>$.result[0].first_name</JSONPath>
</Variable>
</JSONPayload>
<Source clearPayload="false">request</Source>
<VariablePrefix>json</VariablePrefix>
</ExtractVariables>
And a sample AssignMessage policy to help you troubleshooting. If you add this to a proxy with no target it'll send back a simple response with the extracted values:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Message-1">
<DisplayName>Assign Message 1</DisplayName>
<FaultRules/>
<Properties/>
<Set>
<Payload>
npi={json.npi},
last_name={json.last_name},
first_name={json.first_name}
</Payload>
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="response"/>
</AssignMessage>
Sample response from the above:
npi=1671836487,
last_name=HUTTER,
first_name=JOHN
references:
http://apigee.com/docs/api-services/content/extract-message-content-using-extractvariables
http://apigee.com/docs/api-services/content/generate-or-modify-messages-using-assignmessage

You should be able to do this (I didn't test it):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="get-ressults">
<DisplayName>Get Results</DisplayName>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<JSONPayload>
<Variable name="npi">
$.result[*].npi
</Variable>
<Variable name="first_name">
$.result[*].first_name
</Variable>
<!-- etc. -->
</JSONPayload>
<Source>response</Source>
<VariablePrefix>results</VariablePrefix>
</ExtractVariables>

Related

Getting FQTV DATA EXISTS FOR THIS PASSENGER in TravelItineraryModifyInfoRQ

request-
<soapenv:Body>
<ns:TravelItineraryModifyInfoRQ Version="2.1.1">
<ns:CustomerInfo>
<ns:CustLoyalty MembershipID="520000001221" NameNumber="02.01"
ProgramID="EY" RPH="1" />
</ns:CustomerInfo>
</ns:TravelItineraryModifyInfoRQ>
</soapenv:Body>
response-
<soap-env:Body>
<TravelItineraryModifyInfoRS Version="2.1.1"
xmlns="http://webservices.sabre.com/sabreXML/2011/10"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:stl="http://services.sabre.com/STL/v01">
<stl:ApplicationResults status="NotProcessed">
<stl:Error type="BusinessLogic" timeStamp="2018-04-20T13:13:39-
05:00">
<stl:SystemSpecificResults>
<stl:Message>.EY/EY FQTV DATA EXISTS FOR THIS PASSENGER.SEE
ITEM 02</stl:Message>
<stl:Message>.ENTRY NOT PROCESSED BEGINNING WITH</stl:Message>
<stl:Message>FF1¤EY100014486283-02.01</stl:Message>
<stl:ShortText>ERR.SWS.HOST.ERROR_IN_RESPONSE</stl:ShortText>
</stl:SystemSpecificResults>
</stl:Error>
</stl:ApplicationResults>
</TravelItineraryModifyInfoRS>
</soap-env:Body>
Is modification not allowed on membership id.
http://webservices.sabre.com/drc/servicedoc/TravelItineraryAddInfoLLSRQ_v2.2.0_Sample_Payloads.xml
Seems it can be.
It would appear that the FF data for passenger 02.01 is stored in RPH2, and you're attempting to modify 1, while the passenger's data is still in RPH2.
Try modifying the request to RPH 2:
<soapenv:Body>
<ns:TravelItineraryModifyInfoRQ Version="2.1.1">
<ns:CustomerInfo>
<ns:CustLoyalty MembershipID="520000001221" NameNumber="02.01"
ProgramID="EY" RPH="2" />
</ns:CustomerInfo>
</ns:TravelItineraryModifyInfoRQ>
</soapenv:Body>

How do I add SSR OSI to SABRE 2.2.1 API

Below is sample request I made, and below is the response I'm getting.
If you can post sample SpecialServiceRq OSI entry request and response sample that would help a lot.
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<SpecialServiceRQ ReturnHostCommand="false" TimeStamp="2018-03-05T19:02:32.219-05:00" Version="2.2.1" xmlns="http://webservices.sabre.com/sabreXML/2011/10" xmlns:ns2="http://services.sabre.com/STL/v01">
<SpecialServiceInfo>
<SecureFlight SegmentNumber="A">
<PersonName DateOfBirth="1969-02-25" Gender="M" NameNumber="1.1">
<GivenName>LIAM</GivenName>
<Surname>JACKSON</Surname>
</PersonName>
</SecureFlight>
<Service SSR_Code="OSI">
<Text>CTCE/ACCEPT//TEST.CORP.COMPANY.COM</Text>
</Service>
</SpecialServiceInfo>
</SpecialServiceRQ>]
[03-05-18 19:02:32.462] [SplitAgentBooker_10009498321_10009498321_2139481603] INFO SABREpl_timings - : T:0.234 secs S:ABE_ABEBOOKD01_9RVB_000000000002 A:SpecialServiceLLSRS M:2139481603_37114603_37772403_14 RSP: [<?xml version="1.0" encoding="UTF-8"?>
<SpecialServiceRS Version="2.2.1" xmlns="http://webservices.sabre.com/sabreXML/2011/10" xmlns:stl="http://services.sabre.com/STL/v01" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<stl:ApplicationResults status="NotProcessed">
<stl:Error timeStamp="2018-03-05T18:02:32-06:00" type="BusinessLogic">
<stl:SystemSpecificResults>
<stl:Message>.CHECK ENTRY FORMAT.NOT ENT BGNG WITH</stl:Message>
<stl:Message>3OSI CTCE/ACCEPT//TEST.CORP.COMPANY.COM</stl:Message>
<stl:ShortText>ERR.SWS.HOST.ERROR_IN_RESPONSE</stl:ShortText>
</stl:SystemSpecificResults>
</stl:Error>
</stl:ApplicationResults>
</SpecialServiceRS>
If your intention is to create the 3CTCEA/ACCEPT//TEST.CORP.COMPANY.COM-1.1 format, then you don't have to use the SecureFlight node, as that one creates the 3DOCS format.
I would advise to remove it altogether:
<SpecialServiceRQ TimeStamp="2018-03-05T19:02:32.219-05:00" Version="2.2.1" xmlns="http://webservices.sabre.com/sabreXML/2011/10" xmlns:ns2="http://services.sabre.com/STL/v01" ReturnHostCommand="true">
<SpecialServiceInfo>
<Service SSR_Code="CTCE" SegmentNumber="A">
<PersonName NameNumber="1.1"/>
<Text>ACCEPT//TEST.CORP.COMPANY.COM</Text>
</Service>
</SpecialServiceInfo>
This way you will create the above format. If this is not the format let me know which one is and I will help with that one as well.

How to submit XML to Web Service using R [duplicate]

Does anyone know how to formulate following SOAP request with R?
POST /API/v201010/AdvertiserService.asmx HTTP/1.1
Host: advertising.criteo.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "https://advertising.criteo.com/API/v201010/clientLogin"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<clientLogin xmlns="https://advertising.criteo.com/API/v201010">
<username>string</username>
<password>string</password>
<source>string</source>
</clientLogin>
</soap:Body>
</soap:Envelope>
This solves the problem:
library(RCurl)
headerFields =
c(Accept = "text/xml",
Accept = "multipart/*",
'Content-Type' = "text/xml; charset=utf-8",
SOAPAction = "https://advertising.criteo.com/API/v201010/clientLogin")
body = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<clientLogin xmlns="https://advertising.criteo.com/API/v201010">
<username>string</username>
<password>string</password>
<source>string</source>
</clientLogin>
</soap:Body>
</soap:Envelope>'
curlPerform(url = "https://advertising.criteo.com/API/v201010/AdvertiserService.asmx",
httpheader = headerFields,
postfields = body
)

Tsung. How to continue use the previous Jabber session after HTTP switching to and back?

I'm trying to create load testing scenario with tsung. I need to use 2 types of session: ts_jabber and ts_http. May I continue use Jabber session after HTTP switching to and back?
This is my code:
<sessions>
<session probability="100" name="session1" type="ts_http">
//some code
<change_type new_type="ts_jabber" host="*****" port="5222" server_type="tcp" store = "true"/>
<request subst="true">
<jabber type="connect" ack="local">
<xmpp_authenticate username="%%_loginForChat%%" passwd="%%_password%%"/>
</jabber>
</request>
<thinktime value="10"></thinktime>
<transaction name="authenticate">
<request>
<jabber type="auth_sasl" ack="local"></jabber></request>
<request>
<jabber type="connect" ack="local"></jabber> </request>
<request>
<jabber type="auth_sasl_bind" ack="local" ></jabber></request>
<request>
<jabber type="auth_sasl_session" ack="local" ></jabber></request>
</transaction>
<change_type new_type="ts_http" host="******" port="80" server_type="tcp"
//some code
<change_type new_type="ts_jabber" host="*******" port="5222" server_type="tcp" />
<request subst="true">
<jabber type="muc:join" ack="local" room="%%_app_id%%_%%_groupChat_room_id%%" nick="%%_loginForChat%%"/>
</request>
</session>
After run this code i get an error: "Error: Unknown msg {tcp_closed, #Port<0.1183>} receive in state wait_ack, stop"
Help me, please.

SOAP request in R

Does anyone know how to formulate following SOAP request with R?
POST /API/v201010/AdvertiserService.asmx HTTP/1.1
Host: advertising.criteo.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "https://advertising.criteo.com/API/v201010/clientLogin"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<clientLogin xmlns="https://advertising.criteo.com/API/v201010">
<username>string</username>
<password>string</password>
<source>string</source>
</clientLogin>
</soap:Body>
</soap:Envelope>
This solves the problem:
library(RCurl)
headerFields =
c(Accept = "text/xml",
Accept = "multipart/*",
'Content-Type' = "text/xml; charset=utf-8",
SOAPAction = "https://advertising.criteo.com/API/v201010/clientLogin")
body = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<clientLogin xmlns="https://advertising.criteo.com/API/v201010">
<username>string</username>
<password>string</password>
<source>string</source>
</clientLogin>
</soap:Body>
</soap:Envelope>'
curlPerform(url = "https://advertising.criteo.com/API/v201010/AdvertiserService.asmx",
httpheader = headerFields,
postfields = body
)

Resources