Esri request always returning HTML page

587
2
Jump to solution
06-25-2019 06:19 AM
MohamadMousheimish1
New Contributor II

I'm using angular 8. And I'm sending an Esri request to a specific Url.

Here's as snippet of my Code:

Here's the error I'm having when trying to view the response returned by the request:

After googling it, I found out that the response returned by the Esri Request is nothing but the HTML page of the Data I want, and not a Json of the Data.

Here's the response:

So what's the wrong thing I'm doing here ??

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Frequent Contributor II

Update your request options to tell the service to send a json response.

{
  query: {
    f: "json"
  },
  responseType: "json"
}

If not, the server just assumes you want the regular HTML page. You can see how it works in this sample.

https://developers.arcgis.com/javascript/latest/sample-code/request/index.html

View solution in original post

2 Replies
ReneRubalcava
Frequent Contributor II

Update your request options to tell the service to send a json response.

{
  query: {
    f: "json"
  },
  responseType: "json"
}

If not, the server just assumes you want the regular HTML page. You can see how it works in this sample.

https://developers.arcgis.com/javascript/latest/sample-code/request/index.html

JohnGrayson
Esri Regular Contributor

You get the html page because you are not asking for json. Add the "f" (format) value to the "query" options parameter:

esriRequest(url,{query:{f:"json"}}).then(...);