Community
OpenEnergyMonitor

Community

EmonCMS (Ubuntu 16,Apache 2.4, PHP 7) Input POST issue with Java client

Tags: #<Tag:0x00007f6e05c137c8> #<Tag:0x00007f6e05c136b0> #<Tag:0x00007f6e05c135c0>

(Followed the LinuxInstall.md)

If I send an input/post to an emoncms.org account with the fulljson in it the response says:

ok

The response header says:

Connection: close
Content-Length: 2
**Content-Type: application/json**
Date: Thu, 07 Jun 2018 13:24:09 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.25

But if I send exactly the same request an input/post to my local install the response says:

{"success": true}

And the response header says:

Connection: Keep-Alive
Content-Length: 17
**Content-Type: text**
Date: Thu, 07 Jun 2018 13:48:41 GMT
Keep-Alive: timeout=5, max=95
Server: Apache/2.4.18 (Ubuntu)

My Java client uses Spring Resttemplate with:
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML, MediaType.APPLICATION_JSON));

The posting arrives on the server + stored correctly but the client throws an exception:
org.springframework.http.InvalidMediaTypeException: Invalid mime type “text”: does not contain ‘/’

This is due the ‘text’ Content-Type response.

I already added the json mime type to Apache mime.conf. That did not help.

Is this a EmonsCMS bug/issue?
Or did I do something wrong?

Hi,
I’ve added “text/plain” as the “Content-Type” header to this pull request. this should prevent the header parsing errors above.

thanks @Bill.Thomson for the typo spot!

YVW, S!