0

I am developing a little project to understand HTTP requests. For this, I am using a third party API that I call to.

Data Police API

My project has a library of all neighbourhood boundaries in lat and long coordinates. I use these boundary coordinates as a query to API for street level crimes (as mentioned in the document linked below).

Street Level Crimes

Example request:

getComments(): Observable<APIData[]> { return this.http.get<APIData[]> ('https://data.police.uk/api/crimes-street/all-crime?poly=52.268,0.543:52.794,0.238:52.130,0.478&date=2017-01'); }

There are some neighbourhoods that have exceedingly complex boundary coordinates, leading to extremely long URL requests due to query parameters. The document above mentions:

'The API will return a 400 status code in response to a GET request longer than 4094 characters. For submitting particularly complex poly parameters, consider using POST instead.'

How do you use the POST method to return API data to my front end webapp?

2
  • 2
    you'd use return this.http.post... but the API has to support that. Commented Sep 27, 2024 at 18:03
  • yes but this.http.post requires another arugment for the body to send to the API. As in for that it would be: this.http.post(url, bodyargument). so how would I be using POST to retrieve the data, instead of sending data? Commented Sep 28, 2024 at 8:47

1 Answer 1

0

I imagine you should use some like

getData()
{
  const data={poly:....;
            date:'2024-06'
           }
  return this.httpClient.post("https://data.police.uk/api/crimes-street/all-crime",data)
}

but really the API doc is not very clear

NOTE: Yes, post can be use to retrieve data, typical, a login ussually is a API POST call

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.