How the Data Connector for OData sources determines whether it should use JSON or XML.

How the Data Connector for OData sources determines whether it should use JSON or XML.

book

Article ID: KB0080640

calendar_today

Updated On:

Products Versions
Spotfire Connectors 4.5 and Higher

Description

This article describes how the Odata connector determines if it will receive the data from the source in JSON format or in XML format. This can be informational and useful in cases where you end up with not being able to import your data because the source returns the data in XML format but the connector expects JSON format.

 

Issue/Introduction

How the Data Connector for OData sources determines whether it should use JSON or XML.

Environment

TIBCO Spotfire Connector for OData

Resolution

When starting the connector, entering a service URL and pressing connect, the connector sends out a test request to the service requesting JSON data looking like:

GET http://serveraddress:port/odata/ HTTP/1.1
Content-Type: multipart/form-data
Accept: application/json
Host: serveraddress:port
Accept-Encoding: gzip

Connection: Keep-Alive


It then listens to the response it gets back from the service.

The below is an example where the service is set to use XML but still sends back a valid JSON data set due to not properly disabling this on the service:

HTTP/1.1 200 OK
Date: Tue, 05 Apr 2016 08:49:08 GMT
Content-Type: application/xml;charset=utf-8
DataServiceVersion: 1.0
Content-Length: 45
Connection: close

{"d":{"EntitySets":["SampleDataCollection"]}}

 

As there was a JSON data set returned as a response to our test request, the connector will now assume that all data will come in the JSON format as per the standard of working towards OData. Should the service instead have responded with XML, the connector would have seen that this is not valid JSON data and switched over to XML. The metadata for the source is collected directly after, but this is always done over XML regardless if the source is using JSON or XML, but all communication after this will be based on the above test.

Note: Prior to version 4.5, the Odata data connector went through the same steps, but the primary test was requesting XML data instead of JSON data.