question

manu avatar image
manu asked manu commented

HTTP POST response back with HTML not JSON

I am trying to parse the order ID, line item ID from the response of POST call when creating an order and adding line items.

The response getting back is in HTML

Any way to parse the "id" from POST response?

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jacob Abrams avatar image
Jacob Abrams answered manu commented

What is the HTML? Is it a 404 response? Are you prefixing the URL with "api" like apisandbox.dev.clover.com? If you don't use the "api" prefix you may get HTML responses for things like resource not found.

7 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

manu avatar image manu commented ·

Below is the response I get

<code><!doctypehtml>
<html>
<title>
CloverRESTAPIBrowser</title>
<head/>
<body>
<pre>
{"id":"VNGY9XD62QBZ6","orderRef":{"id":"19B28B18CMK4C"},"item":{"id":"RKJM81MBMZ0JW"},"name":"PizzaLarge","alternateName":"LargePizza","price":1099,"printed":false,"createdTime":1449266416000,"orderClientCreatedTime":1449164784000,"exchanged":false,"refunded":false,"isRevenue":true}</pre>
<p>
<ahref="/v3/merchants/xxxx/orders/19B28B18CMK4C/line_items?access_token=4ffcface-xxxx-2e96-11a4-48da68fff91f&return_null_fields=true">
Shownullfields</a>
</p>
</body>
</html>
</code>
0 Likes 0 ·
manu avatar image manu commented ·

Yes i am using api prefix

0 Likes 0 ·
mohammed avatar image mohammed commented ·

If you're using PHP, you can convert the String to an object by json_decode(), then parse the id

0 Likes 0 ·
Jacob Abrams avatar image Jacob Abrams ♦♦ commented ·

Hmm you shouldn't be getting that HTML back, I've not seen that before, hopefully one of my coworkers will know why.

0 Likes 0 ·
manu avatar image manu commented ·

I am using JAVA, when I print the Inputstream I got this result

0 Likes 0 ·
Show more comments
mohammed avatar image
mohammed answered

If you're using PHP, you can convert the String to an object by json_decode(), then parse the id

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

josh avatar image
josh answered

You're sending an accept header that says you would like an html response. Either remove the header:

Accept: html

Or replace it with

Accept: json
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community