cancel
Showing results for 
Search instead for 
Did you mean: 

Odata Connector - Can not Test

vascoeagles
Deputy Chef II
Deputy Chef II

I am attempting to build an Odata connector since there is not one built by Workato.  I have a majority of the code working and I can properly authenticate however I can not get past an error to finalize the connection.  

The error is:

783: unexpected token at '<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0"> <edmx:DataServices> <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="OpenAir.OData.V4.Reports"> <EntityType

The test part of the code is below.  

test: lambda do |connection|
response = get("#{connection['odata_url']}/$metadata")
puts "Response: #{response}"
if response.include?('<edmx:Edmx')
{ success: true, message: "Successfully connected to OData service" }
else
error("Unexpected response from OData service")
end

 

1 ACCEPTED SOLUTION

gary1
Executive Chef III
Executive Chef III

The error reads to me like it's expecting to parse JSON, but it's throwing an error because it's receiving XML. 

There are specific methods to use when working with XML responses from APIs. I would try to implement them:

https://docs.workato.com/developing-connectors/sdk/guides/data-formats/xml-format.html#forming-xml-p...

As a cheaper alternative, you can try `if response.to_s.include?('<edmx:Edmx')` but I don't now if a type conversion will work in this situation. Maybe? Worth a try.

View solution in original post

2 REPLIES 2

gary1
Executive Chef III
Executive Chef III

The error reads to me like it's expecting to parse JSON, but it's throwing an error because it's receiving XML. 

There are specific methods to use when working with XML responses from APIs. I would try to implement them:

https://docs.workato.com/developing-connectors/sdk/guides/data-formats/xml-format.html#forming-xml-p...

As a cheaper alternative, you can try `if response.to_s.include?('<edmx:Edmx')` but I don't now if a type conversion will work in this situation. Maybe? Worth a try.

Thank you!  I was able to get the connections working by simply adding the method.  response_format_xml  - Now i can't get my custom action to work but will take advantage of the link you sent to retrieve xml data.

test: lambda do |connection|
response = get("#{connection['odata_url']}/$metadata")
response.response_format_xml
end,