I need to send a get request with body. Im using angular HttpClient. I understand that get method does not allow to send body, so i'm triyng the request method instead but i cant understand how to use it.
I was able to get data from the exemple bellow without the body part, but i really need to send the body as JSON format.
request(req?: any): any{
const options = createRequestOption(req);
return this.http
.request<ISubscriber[]>("GET", this.resourceUrl,
{
body: '[{"key": "phoneLineType", "operation": ">", "value": "200"}]',
headers: new HttpHeaders({'Content-Type' : 'application/json'}),
params: options,
observe: 'response'
});
}
request
won't change that :get
is just a shorthand forrequest('GET')
. – IrenaPOST
request, look into angular.io/guide/http#making-a-post-request – Rambouillet