Rest API post: Issues with new server

Hi guys,

I keep it simple. I did a regular JSON post on a rest API without any problems for months.

UnityWebRequest req = UnityWebRequest.Post("https://<API URL>?key=" + <KEY>, bodyData);

Now we switched to a simple cloud server. Testing with Postman is successful. Still, I get the following errors:

UnityWebRequest req = UnityWebRequest.Post("http://<IPv4>", bodyData);

if = http://195.XXX.XXX.XX β†’ Cannot connect to destination host
if = http://195.XXX.XXX.XX:3000 β†’ HTTP/1.1 400 Bad Request

Am I missing something here? Are there any preconditions I need to be aware of? Appreciate any help on this topic!

Good to see you curl / Postmanned it first… now you have to find out how that request differs. A proxy such as Charles can be helpful here.

It’s likely just some encoding or header issue that varies between the two stacks.

1 Like

Agreed with Kurt, this may help too https://support.unity.com/hc/en-us/articles/115002917683-Using-Charles-Proxy-with-Unity The important part to remember in your case is to install the Charles root certificate from the Help menu, and REBOOT

2 Likes

Got it working. Will not post the actual reason because - as in most cases - it was just a human mistake. Sorry for taking your time and thanks for your help!

1 Like