I am accessing ArcGIS Server REST API geometry server in a Java application 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 v5.2.0 which is powered by Asp.Net.
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. :
<html lang="en">
<head>
<title>Buffer (GeometryServer)</title>
<link href="https://community.esri.com/arcgis1/rest/static/main.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<table width="100%" class="userTable">
<tr>
<td class="titlecell">
ArcGIS REST Services Directory
</td>
<td align="right"> .......
I did a quick internet search and found a related post on esri's resource-proxy's GitHub page: POST to geometry service for 'PROJECT' is returning HTML instead of JSON · Issue #332 · Esri/resourc...
Is this issue on the resource-proxy GitHub site related to making REST endpoint POST requests from a Java application?
The Java code that I am using to perform the POST request is:
Http httpProtocol = new Http();
HttpRequest request = new HttpRequest();
String reqBody = 'geometries=-78.868242630049537,35.773265772338988&inSR=4326&outSR=4326&bufferSR=102113&distances=1000&f=json';
Integer bodyLength = reqbody.length();
request.setEndPoint('http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/buffer');
request.setMethod('POST');
request.setBody(reqBody);
request.setCompressed(true);
request.setHeader('Accept', 'application/json');
request.setHeader('Content-type', 'application/json' );
request.setHeader('Content-Length', String.valueOf(bodyLength));
HttpResponse response = httpProtocol.send(request);
system.debug('response.getBody(): ' + response.getBody());
system.debug('response: ' + response);
Has anyone else had this issue or know of a work around? Any help or suggestions will be greatly appreciated.
Thanks, Tyler