cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2074
Views
0
Helpful
13
Replies

UCCX HTTP Post

Ahmed Adeyemi
Level 4
Level 4

Working on a script to collect customer data and send it to a URL. I am able to conduct the HTTP post to send the URL via create document. But i have a couple of questions:

 

1. When i send the HTTP Post, would i get a response back if i use a create XML document step?

2. I am anticipating on getting the response data in HTML Format below and was wondering how i can either format this to XML so i can collect and play "Auth=PRE7892" as the response to the end customer as a reference code.

 

 

HTML Format for Response:

<html>

   <head>

      <meta content="HTML Tidy for Java (vers. 26 Sep 2004), see www.w3.org" name="generator"/>

      <title/>

   </head>

   <body><![CDATA[CoreID=54542734&REFNO=ACK956&Auth=PRE7892&SAVCode=B&BVN2ResponseMsg=M&Notes=&User1=123&User2=44&User3=22&User4=]]></body>

</html>

2 Accepted Solutions

Accepted Solutions

Based upon the data provided, I mocked up a Sample Response.

2018-0921-SampleParseResponse.PNG

This sample script simulates the response (your data from the previous message) and assigns the parsed string of type array into string variables that can be used as responses to your callers query.

 

Let me know if this helps.

View solution in original post

Thanks Sean. I was able to finally figuring out the way to receive the information. In 11.6, you are now able to use REST. So once i received the expected string as part of the response (Variable strBody), i now wrote a set step "Integer.parseInt(strBody.split ("&") [1].split("=")[1])" which essentially deletes everything else and passes me the transNr.

View solution in original post

13 Replies 13

Sean Lynch
Level 7
Level 7
I'd like to help you with this. Yes, you use the create XML document step to retrieve the data. I would need a little more info about the query and response. Let me know if you are interested in collaborating.
-Sean

Yes i am definitely interested in collaborating. I figured i would use the Get XML Document to retrieve the information but then i am confused on how i can convert the information from a HTML looking response to XML.

 

I know worse case scenario, i will use substring to remove the information and only keep what i'm looking for but i was also thinking if they were any other methods such as using Keyword Transform and all.

I think you are on the right track.  Try it out.  Run it through the interactive step editor and see what the system does with the output of the step.  Collect the document data from the "Create URL Doc - Post" step into a "Create XML Doc" step.  Capture the output from the variable pane.  It may already be formatting it in a way that can be parsed by the next "Get XML Document Data" step.  If not, then, I think it will be the substring route...

 

2018-0824-simplePOST.PNG

IF possible, post the document output from the variable pane of the "Create XML" step.

 

-Sean

That's what i am doing right now. The problem becomes how do i format the get XML Document. Instead of using the normal XPATH like i would normally do, i am using the descendant method hoping to collect something so i can see at least how its formatted. So in this case i created in the XML Path area, i am putting in "/descendant:body" to output to my string called strBody. I am yet to run the test on this but when i do, i would let you know if it captures the data.

So the body portion of the HTML is the part you want to capture as a string. 

I think the XPATH would look more like  "//body" (based upon the original info you posted).

...that's if the document returned doesn't need more manipulation.  That's why I asked if you would paste the data (in text) from the variable pane for the document output from the create xml doc step. 

Not sure if this will work, and may need a different approach--but I wanted to follow the same line you were on, first.

-Sean

So I tested this in my lab and created a similar scenario.   The response to the HTTP Get query is not returned in a XML parse-able format, but rather a standard HTML page.  In looking at the data, I found that in my case, the data returned was consistent enough to convert the HTML data into a string and use the SPLIT function to parse the table data into an array.  From there, I was able to use a loop and load the data into the desired result strings:

Example:

2018-0919-httpsQuerySample2.PNG

 

Now, I realize this is not exactly what the original request (above) was trying to solve, but the scripting is/could be similar.

 

Maybe this example will help someone with their process/requirement. 

 

-Sean 

 

So attached is the script that has the URL part. If you run this URL on the software called POSTMAN, you will see the response. It doesnt quite come in HTML or XML. Its in JSON. I am still totally lost on how to get a response back. but if i run it in postman, i see the response and i do see it posting as well. I hope you can provide more options as to how i can get response back.

 

Here is what the response looks like

 

"ResponseCode=11&tranNr=0000414128123&PostDate=2017-10-14T11:33:53.000&Amount=000000001000&Auth=Lem10&SiteCode=&CWEResponse=&CABBResultCode="

Sorry, attached the wrong one.

Based upon the data provided, I mocked up a Sample Response.

2018-0921-SampleParseResponse.PNG

This sample script simulates the response (your data from the previous message) and assigns the parsed string of type array into string variables that can be used as responses to your callers query.

 

Let me know if this helps.

Thanks Sean. I was able to finally figuring out the way to receive the information. In 11.6, you are now able to use REST. So once i received the expected string as part of the response (Variable strBody), i now wrote a set step "Integer.parseInt(strBody.split ("&") [1].split("=")[1])" which essentially deletes everything else and passes me the transNr.

Cool! Good job!

-Sean

By the ways, do you mind sending me the script you posted so i can see how you did it?

 

Yes i am definitely interested in collaborating. I figured i would use the Get XML Document to retrieve the information but then i am confused on how i can convert the information from a HTML looking response to XML.

 

I know worse case scenario, i will use substring to remove the information and only keep what i'm looking for but i was also thinking if they were any other methods such as using Keyword Transform and all.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: