I need to send json on the BODY in a GET request using ionic native http or whatever

I need to do something, which I do in any other language, anything. Call an API via http, by “get request”, sending a json in the body. Simple.

But from what I’ve seen, the native ionic http doesn’t have that. Only “post” and “put” can send json in the body, “get” doesn’t, can only send “parameters”.

Well, is there any plugin, some magic, some workaround to be able to do this? I’ve already searched on the net, google and etc, and only comes a “post” or “put” sending json…

Please, could someone help me…?

Not simple at all.

Bodies in GET requests have no defined meaning, according to RFC 7231. Any server or proxy you are dealing with is perfectly within its rights to drop your body on the floor.

There are conventions for REST endpoints, among them that GET requests cannot modify externally visible state and may be repeated an unspecified number of times without adverse effect.

They really are for queries - getting things. If you need to specify query parameters, use HttpParams - they will be appended to the query string of the URL.

If you don’t want the stuff you are trying to put in the body in the URL, that is a very strong indicator that the endpoint is misclassified in the first place, and should be a POST instead (or a PUT if you’re OK with it being done multiple times).

If you would like to give more detail as to what this endpoint does, perhaps you will get some more feedback on whether you should move the body stuff into the URL and stick with GET or leave the body stuff in the body and switch to another method.

Those are the only standards-compliant options, which is why Angular’s HttpClient does not take bodies in its get method.

I understand… Thanks