Get Request problem "Response does not have a media type"

Hello,
I want to call the WTO API, but I have a strange problem. It seems that Knime has a problem when this API returns the result as json.
When I call the API with this URL: https://api.wto.org/timeseries/v1/data?i=ITS_MTV_AX and my API key: XYZ with Postman, it works fine. If I do the same in KNIME, the body is missing, status = 200 and I get the error message: ‘Response does not have a media type’.
I have already tried several additional request headers and nothing has changed. I have also tried a more specific API call with this URL, same problem:

https://api.wto.org/timeseries/v1/data?i=ITS_MTV_AX&r=004,008,012,016,020,024,660,028,032,051,036,040,031,044,048,050,052,112,056,058,084,204,060,064,068,070,072,076,096,100,854,108,132,116,120,124,136,964,140,148,152,156,170,174,178,184,188,384,191,192,531,196,203,180,208,262,212,214,218,818,222,226,232,233,748,231,918,234,242,246,250,258,260,266,270,268,278,276,288,292,300,304,308,316,320,324,624,328,332,340,344,348,352,356,360,364,368,372,376,380,388,392,400,398,404,296,408,410,414,417,418,428,422,426,430,434,440,442,446,450,454,458,462,466,470,584,478,480,175,484,583,498,496,893,500,504,508,104,516,520,524,528,530,533,540,554,558,562,566,570,807,580,578,512,586,585,591,598,600,604,608,616,620,634,642,643,646,659,662,666,670,882,678,682,686,892,891,690,694,702,534,703,705,090,706,710,728,724,144,736,740,752,756,760,158,762,834,764,626,768,772,776,780,788,792,795,796,798,810,800,804,784,826,840,888,858,860,548,862,704,092,876,887,890,894,716&p=default&ps=default&pc=TO,AG,AGFO,MI,MIFU,MA,MAIS,MACH,MACHPH,MAMT,MAMTOF,MAMTOTEP,MAMTOTTL,MAMTOTIC,MAMTTE,MAMTAU,MATE,MACL&spc=false&fmt=json&mode=full&dec=default&off=0&max=500&head=H&lang=1&meta=false

If I replace the fmt=json with fmt=csv I get something back, but in a ugly format.

Some ideas?

Thank’s a lot!

Hi @ESGKNIME , welcome to the KNIME community.

Unfortunately the URL for the API that you posted doesn’t give much in the way of clues without an authorisation token. Do you have a link to any documentation for this api that is viewable publicly so people can assist more easily?

Also, some quick questions that may also be useful for people helping you…

  • Which KNIME node(s) are you using for the API calls?

  • Is this a GET request?

  • What content-type / media-type do you expect the returned data to have?
    e.g. application/json ?

  • What configuration are you using in the KNIME node to access the api,
    e.g. are you setting Accept Headers?

4 Likes

Thank you for your response!

I’m using the get request node.
The API returns json or csv, I want to have json.

I have set Headers like Accept application/json.

I have called this api before to get some indicators. This worked fine.


The only header which is set here is for the API key and it works.

I have use the get request node several times before with different API’s but I have never had such a problem.

1 Like

The message indicates that the API is not returning a Content-Type header. You can verify this with Postman, it shows all response headers.

1 Like

Here you can see the headers. You are right.

The screenshot shows the request headers. However, the problem is supposedly in the response headers from the API.

1 Like

ah, sorry

These REST nodes behave very … academic. Entirely correct, yet not very pragmatic.

If you just want to do your request, you can try e.g. the HTTP Retriever from the Palladian nodes - it will not bother with missing headers and just return you the raw data. Convert it to a string then parse it to JSON and you should be settled:

Hope that helps!

5 Likes

Super!
works, thank you very much!
You never stop learning :wink:

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.