cancel
Showing results for 
Search instead for 
Did you mean: 

Processing OData Responses

darren-davies
Deputy Chef I
Deputy Chef I

Hi All,

I'm trying to process an odata response from an external system.  The response has odata attributes that are needed, but are coming through as null when mapped in the HTTP response schema.  The entries within the "value" list correctly map, it's only the odata attributes that are missing.

The response has the structure:

{
"@odata.context": "serviceRoot/$metadata#People",
"value": [ ...... ],
"@odata.nextLink": "serviceRoot/People?%24skiptoken=8"
}

The @odata.nextLink is the value that is needed.

The ResponseSchema maps the "@odata" to "_odata" and flags errors when editing the field in the UI.  Editing the JSON schema appears to work.

Has anyone successfully pulled odata attributes and has any pointers as to where I could be going wrong?

Thanks,

Darren.

 

 

5 REPLIES 5

meghan-legaspi
Community Manager
Community Manager

Hey @darren-davies, were you able to get this resolved? If not, I recommend reaching out to your Workato rep as a next step. Please let me know if you need assistance getting in touch.

Thank you,
Meghan

DavidB
Deputy Chef I
Deputy Chef I

Hi!

We had the same problem. 

We used the JSON to Schema function for the connector. This works, but gave the following schema:

Body (Object)
    Odata 2e context (string)
    Value (list)
       All the values... (Strings, numbers etc)
    Odata 2e Nextlink (String)
Headers (Object)
    
A bunch of header items (Strings)  

The json response is correct and workato can use the datapills in the recipe. However it all returns as blank. The problem is workato cant handle the Object-layer of the schema. We had to change the schema to:

Odata 2e context (string)
Value (list)
   All the values... (Strings, numbers etc)
Odata 2e Nextlink (String)
A bunch of header items (Strings)  

Json response looks exactly the same but now I can use the data for stuff.

Next challenge is finding a good way to emulate a "while" function for this odata nextlink.

darren-davies
Deputy Chef I
Deputy Chef I

Hi David,

Thanks for the response.  I'll have a play with the response schema and see if I can get it working that way.  I have a ruby action using a regex at the moment, which is fairly hideous! 🙂

For the looping, I created a couple of variables:

  • a repeat helper list long enough to cover the maximum likely number of calls (I have a reasonable idea of the maximum number of records that can be returned)
  • a variable for the the request criteria - initially set to the full query string value

The code then uses the repeat helper list to loop.  Within the loop, the code checks the request criteria is populated and if so, makes the OData call, extracts the nextLink, and updates the request criteria with the nextLink skip value.

Essentially looping on while the request criteria is populated.

Hope that makes sense and help.

Thanks, D.

DavidB
Deputy Chef I
Deputy Chef I

Hi!

Current setup for us is a helper list with a "stop job" if the odatalink is not present. It gives me the option to just have the repeater helper be set to the max 50k. Will do some experiments with callable recipes to see what works best.

Callable recipes are not recursive but in theory I could have 2-3 of them with some concurrency. Ask me again on monday 😀
I think callable recipes makes it look a bit cleaner, but in the end I want performance and as few tasks as possible.

How do you handle the following results? Do you merge them somewhow? If you have a nice ruby script for that I'd love to try it myself. There are some community rubys for it but they require  mapping which I'd rather avoid.

/David