<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ArcGIS Server REST API HTTP POST Returning HTML form instead of JSON in ArcGIS REST APIs and Services Questions</title>
    <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/arcgis-server-rest-api-http-post-returning-html/m-p/478834#M2293</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am getting a similar thing with the server returning the query form, but no response. I've tried various combinations of the request parameters (using PHP) but the main parts of the code are:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$fields = json_encode($payload);&lt;/P&gt;&lt;P&gt;$headers = array(&lt;BR /&gt; 'Accept: application/x-www-form-urlencoded',&lt;BR /&gt; 'Content-Type: application/x-www-form-urlencoded'&lt;BR /&gt; );&lt;BR /&gt; $ch = curl_init();&lt;BR /&gt; curl_setopt($ch, CURLOPT_URL, $url);&lt;/P&gt;&lt;P&gt;$options = array(&lt;BR /&gt; CURLOPT_RETURNTRANSFER =&amp;gt; true,&lt;BR /&gt; CURLOPT_HTTPHEADER =&amp;gt; $headers,&lt;BR /&gt; CURLOPT_HTTPGET =&amp;gt; true,&lt;BR /&gt; CURLOPT_POST =&amp;gt; true,&lt;BR /&gt; CURLOPT_POSTFIELDS =&amp;gt; array('f'=&amp;gt;'html','features'=&amp;gt;$fields)&lt;BR /&gt; );&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; curl_setopt_array( $ch, $options );&lt;BR /&gt; $response = curl_exec($ch);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My result is often returned as either the form, or with other variations of the POSTFIELDS array - either NULL, or empty.&lt;/P&gt;&lt;P&gt;I can paste the values into the addFeatures page within the online interface, and the same 'features' parameter works from the box.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anybody have any ideas why this might be happening. I''ve also tried json verions for the Accept and Content-Type headers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 25 Oct 2019 12:06:12 GMT</pubDate>
    <dc:creator>BrendonO_Hanlon</dc:creator>
    <dc:date>2019-10-25T12:06:12Z</dc:date>
    <item>
      <title>ArcGIS Server REST API HTTP POST Returning HTML form instead of JSON</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/arcgis-server-rest-api-http-post-returning-html/m-p/478832#M2291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am accessing ArcGIS Server REST API geometry server in a Java application&amp;nbsp;to do some analysis. I expect to be buffering lines and polygons and plan to use a post request due to the length restrictions on a 'GET' request. I have structured my HttpRequest's endpoint and body correctly and verified my response using Postman&amp;nbsp;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 12px;"&gt; v&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 12px;"&gt;5.2.0 which is powered by Asp.Net.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 12px;"&gt;I am using Java to make requests to the geometry server. When I make a geometry server buffer request from my Java application, I get a 200 status. However, the response from the server is not a buffer response. Instead, my response is the HTML form from the buffer tool's endpoint. I.E. :&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 12px;"&gt;&amp;lt;html lang="en"&amp;gt;&lt;BR /&gt;&amp;lt;head&amp;gt;&lt;BR /&gt;&amp;lt;title&amp;gt;Buffer (GeometryServer)&amp;lt;/title&amp;gt;&lt;BR /&gt;&amp;lt;link href="https://community.esri.com/arcgis1/rest/static/main.css" rel="stylesheet" type="text/css"/&amp;gt;&lt;BR /&gt;&amp;lt;/head&amp;gt;&lt;BR /&gt;&amp;lt;body&amp;gt;&lt;BR /&gt;&amp;lt;table width="100%" class="userTable"&amp;gt;&lt;BR /&gt;&amp;lt;tr&amp;gt;&lt;BR /&gt;&amp;lt;td class="titlecell"&amp;gt;&lt;BR /&gt;ArcGIS REST Services Directory&lt;BR /&gt;&amp;lt;/td&amp;gt;&lt;BR /&gt;&amp;lt;td align="right"&amp;gt; .......&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 12px;"&gt;I did a quick internet search and found a related post on esri's resource-proxy's GitHub page:&amp;nbsp;&lt;A class="link-titled" href="https://github.com/Esri/resource-proxy/issues/332" title="https://github.com/Esri/resource-proxy/issues/332"&gt;POST to geometry service for 'PROJECT' is returning HTML instead of JSON · Issue #332 · Esri/resource-proxy · GitHub&lt;/A&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 12px;"&gt;Is this issue on the resource-proxy GitHub site related to making REST endpoint POST requests&amp;nbsp;from a Java application?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 12px;"&gt;The Java code that I am using to perform the POST request is:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Http httpProtocol = new Http();&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;HttpRequest request = new HttpRequest();&lt;BR /&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;String reqBody = 'geometries=-78.868242630049537,35.773265772338988&amp;amp;inSR=4326&amp;amp;outSR=4326&amp;amp;bufferSR=102113&amp;amp;distances=1000&amp;amp;f=json';&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Integer bodyLength = reqbody.length();&lt;BR /&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;request.setEndPoint('&lt;SPAN style="color: #505050; background-color: #fafafa;"&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fsampleserver1.arcgisonline.com%2FArcGIS%2Frest%2Fservices%2FGeometry%2FGeometryServer%2Fbuffer" rel="nofollow" target="_blank"&gt;http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/buffer&lt;/A&gt;&lt;/SPAN&gt;');&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;request.setMethod('POST');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;request.setBody(reqBody);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;request.setCompressed(true);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;request.setHeader('Accept', 'application/json');&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;request.setHeader('Content-type', 'application/json' );&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;request.setHeader('Content-Length', String.valueOf(bodyLength));&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;HttpResponse response = httpProtocol.send(request); &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;system.debug('response.getBody(): ' + response.getBody()); &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;system.debug('response: ' + response);&lt;BR /&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 12px;"&gt;Has anyone else had this issue or know of a work around? Any help or suggestions will be greatly appreciated.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 12px;"&gt;Thanks, Tyler&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 12px;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Sep 2017 16:41:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/arcgis-server-rest-api-http-post-returning-html/m-p/478832#M2291</guid>
      <dc:creator>TylerWaring</dc:creator>
      <dc:date>2017-09-18T16:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Server REST API HTTP POST Returning HTML form instead of JSON</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/arcgis-server-rest-api-http-post-returning-html/m-p/478833#M2292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;Greetings,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;It turns out that both the 'Accept' and 'Content-Type' headers need to be set to '&lt;SPAN&gt;application/x-www-form-urlencoded'&lt;/SPAN&gt;&amp;nbsp;.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;i.e&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;request.setHeader('Content-Type', 'application/x-www-form-urlencoded');&lt;BR /&gt; request.setHeader('Accept', 'application/x-www-form-urlencoded')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;Thanks to Nick from ESRI support&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;Best, Tyler&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;P.S. also be sure not to compress the data. i.e.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;request.setCompressed(true);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;you can however set the content length. i.e.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;request.setHeader('Content-Length', String.valueOf(bodyLength));&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Sep 2017 18:37:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/arcgis-server-rest-api-http-post-returning-html/m-p/478833#M2292</guid>
      <dc:creator>TylerWaring</dc:creator>
      <dc:date>2017-09-20T18:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Server REST API HTTP POST Returning HTML form instead of JSON</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/arcgis-server-rest-api-http-post-returning-html/m-p/478834#M2293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am getting a similar thing with the server returning the query form, but no response. I've tried various combinations of the request parameters (using PHP) but the main parts of the code are:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$fields = json_encode($payload);&lt;/P&gt;&lt;P&gt;$headers = array(&lt;BR /&gt; 'Accept: application/x-www-form-urlencoded',&lt;BR /&gt; 'Content-Type: application/x-www-form-urlencoded'&lt;BR /&gt; );&lt;BR /&gt; $ch = curl_init();&lt;BR /&gt; curl_setopt($ch, CURLOPT_URL, $url);&lt;/P&gt;&lt;P&gt;$options = array(&lt;BR /&gt; CURLOPT_RETURNTRANSFER =&amp;gt; true,&lt;BR /&gt; CURLOPT_HTTPHEADER =&amp;gt; $headers,&lt;BR /&gt; CURLOPT_HTTPGET =&amp;gt; true,&lt;BR /&gt; CURLOPT_POST =&amp;gt; true,&lt;BR /&gt; CURLOPT_POSTFIELDS =&amp;gt; array('f'=&amp;gt;'html','features'=&amp;gt;$fields)&lt;BR /&gt; );&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; curl_setopt_array( $ch, $options );&lt;BR /&gt; $response = curl_exec($ch);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My result is often returned as either the form, or with other variations of the POSTFIELDS array - either NULL, or empty.&lt;/P&gt;&lt;P&gt;I can paste the values into the addFeatures page within the online interface, and the same 'features' parameter works from the box.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anybody have any ideas why this might be happening. I''ve also tried json verions for the Accept and Content-Type headers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2019 12:06:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/arcgis-server-rest-api-http-post-returning-html/m-p/478834#M2293</guid>
      <dc:creator>BrendonO_Hanlon</dc:creator>
      <dc:date>2019-10-25T12:06:12Z</dc:date>
    </item>
  </channel>
</rss>

