Skip to content
Advertisement

2ba web API post request with php curl

Im using 2ba its API to receive product information which I later on want to store inside my database. I am trying to create a post request for receiving the data I need. This is the request I want to get to working. And this is my code:

postApiData.php

JavaScript

index.php

JavaScript

My API key does for sure work since I have done alot of different GET requests already, also im not getting an access denied error.

The error I get with this code is: The requested URL returned error: 500 Internal Server Error I also receive a “Bad request” 400 error when I remove the curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($parameters)); part

Is there anyone who knows what im doing wrong?

PS: It’s not really possible to try this code yourself unless you have a 2ba account with working key’s etc.

Advertisement

Answer

Okey I fixed it already…

I had to add some extra headers and change the $parameters values like this:

postApiData.php

JavaScript

index.php

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement