cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BODS HTTP Adapter compatibility with JSON Reply

Former Member
0 Likes
3,364

Hi All-

I am using BODS 4.2 and need to consume a REST Based API service (using both GET and POST). I have already configured the BODS Out-of-the-box HTTP Adapter and created an operation for the GET service and was able to import that as a message function in my Designer(as a DATASTORE object)-shown below:

However, my issue is that when I try calling my GET operation in a data-flow, it errors out with an XML parser failed error as below:

Briefly, whats happening is that the BODS Adapter expects an XML Response whereas the URL(which hosts the API) throws a JSON output file at it. Somehow, BODS OOTB HTTP Adapter doesn't support JSON reply format. Is there a workaround/alternative?

Any guidance is much appreciated-

Thanks in advance,

Abhishek

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

You can create  a JSON Adapter for GET response

Refer to below link

You might need to develop a JSON adapter using Java SDK ,that obtains data via HTTP in JSON-format, converts it to XML and passes to Data Services.


Although nobody has posted the exact steps but you may find an excerpt below



Regards

Arun Sasi

Former Member
0 Likes

Thanks Arun.

I have visited both the blogs and can see that both of them employ other open source tools like a JAVA SDK or a python Library like urllib2. I am more inclined to use Python due to its easy integration with User Defined functions in BODS but I haven't figured out the complete solution yet. The difference between what's shown in the blog How to use a Base_UserDefined Transform in Data Services 4.x to return JSON Web Service data

versus my URL is that mine returns a file output whereas the one in the blog displays the result on the browser directly. My URL API service also uses authentication. When I modified the python code in the editor and tried I got an error which said 'No JSON object could be decoded'


From the looks of it, I now feel that this might be due to the way my API works(can't disclose the actual URL, owing to security issues). I'm referring this back to the DQ community for some suggestions - please have a look-

Thanks,

Abhishek

Message was edited by: Abhishek Ghosh The referred blog post within my reply was incorrect. I have now posted the correct one-

former_member187605
Active Contributor
0 Likes

I am sorry, but am I missing something?

Support of JSON files and messages as batch and real-time sources and targets was introduced in DS 4.2 SP2.

RESTful web services are natively supported with the Webservice adapter since DS 4.2 SP1.

The post is over 4 years old. A lot has changed since then.

Former Member
0 Likes

Hi Dirk- I expected the same when I started this activity but couldn't find anything related on SCN. As per my DS installation , I have DS 4.2 support pack 3; shown below:

I haven't worked with HTTP Adapters earlier and can do with some additional help. Could you please point me to some resources which can be useful? I couldn't see the technical manuals don't explicitly speak about JSON support for HTTP Adapters though. I'm not sure if I have the latest documentation-

Thanks,

Abhishek

former_member187605
Active Contributor
0 Likes

There is a more recent version of the documentation:

Get it from help.sap.com.

Work with the WebService adapter (not the HTTP adapter!)

and create a data store of type Web Service REST:

Former Member
0 Likes

I downloaded the latest documentation from help.sap.com and created a Web-service Datastore with my URL which produces a JSON Output file:

Next I tried to import the available functions for the web-service and this is the error that I got:

Is there something that I missed or is the URL I'm using the reason for this?

Thanks in advance,

Abhishek

former_member187605
Active Contributor
0 Likes

You forgot to include the error message.

Former Member
0 Likes

Apologies, missed the error screenshot in my earlier message. Here it is now. I even tried creating a new DataServices,html file in the folder indicated above with the following content-

The result is the same error on trying to open the Datastore in designer.

former_member187605
Active Contributor
0 Likes

You've selected a wrong data store type. Create a data store of type Web Service REST as indicated above.

Former Member
0 Likes

Okay Dirk-I changed to the Web Service REST Datastore; defined it as shown below:

However, it doesn't save properly and when I click OK on the final dialog box it throws the error below:

It seems an XML parser comes into play even after I selected a JSON mediatype(above). Is there something else I need to change?

Thanks,

Abhishek

former_member187605
Active Contributor
0 Likes

You need a correct wsdl or wadl file. I cannot verify, because you blanked out the url.

Former Member
0 Likes

As I cannot share the URL I have used as of now due to preserve confidentiality, will it be possible for you to use the URL mentioned in the post below?, i.e the URL-http://data.consumerfinance.gov/api/views.json

http://scn.sap.com/community/data-services/blog/2013/01/31/how-to-use-userdefined-transform-in-sap-b.... If you can make it work with the Web Service Datastore it would be great if you can publish the settings; as such I tried with it and got the same XML parser error-

former_member187605
Active Contributor
0 Likes

Without the schema definition (wsdl/wadl) file I cannot do anything.

Answers (0)