0

This is what I'm using to make the call:

 const httpOptions = {
    headers: new HttpHeaders({
      'Content-Type': 'application/json'
    })
  };

   this.http.post("https://fakedomain.com/info.php", { "uuid": this.device.uuid, "funcion": "saveFormulario"}, httpOptions).subscribe(response => {
    this.datos = response;
  });

And this is all the info the server is getting:

POST /info.php HTTP/1.0

HTTP headers:
Host: fakedomain.com
X-Forwarded-Proto: https
Accept-Encoding: gzip, deflate, br
Connection: close
Pragma: no-cache
Cache-Control: no-cache
Accept: application/json, text/plain, */*
Origin: http://192.168.0.118:8100
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1
Referer: http://192.168.0.118:8100/
Accept-Language: en-US,en;q=0.9,es;q=0.8

Request POST:

Request GET:

Request body:
{"uuid":"testuuid","funcion":"saveFormulario"}

So the info is getting sent, but nothing on the $_POST side.

What am I doing wrong?

8
  • What's the server response? Any exceptions in server logs? Commented Mar 12, 2019 at 18:09
  • Looks like a server side (php) issue, nothing to do specifically with angular. I would look at how your mapping is setup. You can isolate this more by using PostMan instead of angular as your testing client. Commented Mar 12, 2019 at 18:17
  • This might not be an angular issue. I am not a php guy and I am not sure if the params are case sensitive but perhaps you are using the wrong case for param names (uuid vs uuId, etc). Also make sure you are using the right spelling for second param, funcion vs function. Commented Mar 12, 2019 at 18:20
  • @Igor well in postman I can fake the call and receive the post data... Really weird. Commented Mar 12, 2019 at 18:23
  • Then compare the parameters in postman to what is being sent in angular. What is the difference? Commented Mar 12, 2019 at 18:25

1 Answer 1

1

This is what fixed the issue:

const httpOptions = {
  headers: new HttpHeaders({
    'Content-Type': 'application/x-www-form-urlencoded'
  })
};
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.