KNIME RESTful Nodes: response status 200 with empty body

Dear fellow KNIMErs,

I have a similar issue to this one:

The solution of that one was to use the Palladian http-nodes, which I can confirm acts as a workaround to the issue in the Analytics Platform. However, that is not a solution for the KNIME Server we are running, where I’d like to use standard nodes as much as possible.

This is what I get in KNIME:
image
This is what I get in Postman:

Did anyone figure out a way to get this working with the standard RESTful nodes?
Thanks & BR
Alex

1 Like

Just a guess:

You’re getting a JSON content type in postman but a text/plain type in KNIME? Have you specified an Accept header? If so you could try removing this or setting it to application;json; charset=UTF-8 or something similar.

Cheers

Sam

1 Like

Hi Sam,
thanks for the quick response!
Sorry, I did forget to post the headers that I’m sending (which are the same between Postman & KNIME):

I also now added the “Accept” header with value “application/json; charset=UTF8” as suggested by you, and it shows “text/plain” in the response Content Type nonetheless.

BR Alex

Just in case it matters did you use “application/json; charset=UTF8” or “application/json; charset=UTF-8” (UTF-8)?

It looks like KNIME thinks you’ve been sent an empty plain text string as a response. I’m afraid I don’t have any ideas to suggest.

Cheers

Sam

Hi Sam,
thanks for the attention to detail. Indeed I was sending “UTF8” instead of “UTF-8”.
I corrected that and tried again, both by including that in an extra “Accept” header like this:


…or by including it in the Content-Type like this:

In both cases, KNIME still thinks that I’m getting an empty plain text string in the response:
image

BR Alex

Hi Alex,

that’s an interesting issue. A small observation- it seems that your situation differs from the thread that you’ve linked at the beginning- they got an missing body (the red question mark), while you get the body not displayed (blank white space).

Could you try to dump the resulting table into a file to check if the cell has any contents? And maybe check what does the “Spec” tab show for the possible values in the body column. I wonder if maybe the problem is not with wrong type of returned payload, but rather with displaying the content, similar to what has been observed in Problem while concatenating via the GroupBy node Value 0 ?

Cheers,
Mischa

1 Like

Thanks Mischa,
I tried the suggestion from Problem while concatenating via the GroupBy node Value 0 by copying + pasting the contents into a text editor (Notepad++ or normal Notepad) and can confirm that it’s completely empty (not even a space). So it seems to be something else in this case.

The “Spec” Tab shows the following:

As a workaround, I just installed Anaconda Python on my KNIME Server & my laptop running the KNIME Analytics Platform, and then used the “requests” package to do the work for me (like shown here: Delete Request with body). That way I can work with KNIME Server again (even though I’m not completely happy with this solution).

Best regards,
Alex

1 Like

I have seen a similar set of red question marks in the body column, along with 200 in the status column for a set of URLs such as
https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/inchikey/KVDAKRXRZYHBMP-UHFFFAOYSA-N/SDF
One out of every 30, or so, works correctly and returns a non-blank body.

Hi @ChemMitch,

I don’t think this is related to the issues they people had above. Is the link working when you send a GET request? I tried and the body wasn’t empty. Also when you try the link online it has content.
Could you please share an example that isn’t working please? Sometimes, and I think this is also happening here, the WebServices don’t have any data to provide and then the body is empty and contains a red question mark.

Best,
Martyna

1 Like

Hi Martyna,
Sorry; yes, it’s correct that my results were from a GET. But, as you can see

the body is empty.
Here are some of the URLs text.https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/inchikey/OGHNVEJMJSYVRP-UHFFFAOYSA-N/SDF
https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/inchikey/SYGWGHVTLUBCEM-ZIZPXRJBSA-N/SDF
https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/inchikey/IUKJNIOSXCPLLP-UHFFFAOYSA-N/SDF
https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/inchikey/FNTDGCHSJHAFAV-UHFFFAOYSA-N/SDF
https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/inchikey/ZVIYWUUZWWBNMB-VICXVTCVSA-M/SDF
https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/inchikey/TXKOGNLDVKUFSI-WZTVWXICSA-N/SDF
Note that within, for example, Firefox, they do result in an SD file for download.

What can I do within KNIME to get the data to process?

I’ve had a similar issue to you. Hopefully someone has a solution but for now I can offer you a workaround.

public String read(String url) throws Exception
{
   URL sdf = new URL(url);
   BufferedReader in = new BufferedReader(new InputStreamReader(sdf.openStream()));

   StringBuffer buffer = new StringBuffer();
  
   String inputLine;
   while ((inputLine = in.readLine()) != null)
      	buffer.append(inputLine + "\n");
   in.close();


     return buffer.toString();
}
try 
{
	out_structure = read(c_URL);
} catch (Exception e)
{
	logError(e);
	out_structure = null;
}

image

If we use the Get node:

The error message for the missing cells is Duplicate key detected: “binaryObject-0”. Is the KNIME node trying to make this a JSON object?

EDIT: Doing this in a chunk loop works so looks like it may be storing something globally which is throwing off the next row iteration?

Cheers

Sam

1 Like

Thank, Sam! The Java Snippet works great.

1 Like

Hi @ChemMitch and @swebb -

Sorry for the trouble. We do have a ticket open for this issue (internal reference: AP-13369) and I’ll add a +1 from you on that.

2 Likes