Skip to content
Advertisement

API working well on POSTMAN but giving error in Curl PHP

I am trying to fetch the record from the api. It’s working correctly on postman but giving the error when I use curl in php.

Here is my PHP Code:

JavaScript

Here is the error I am getting after curl: error after curl option

On the Postman it’s giving the result perfect as expected: postman result

Furthermore api url working perfect without any parameters on search. it is also working fine if we use the zip_code filter like this zipcode filter the only issue is with $where=provider_number in(“017000″,”017037″,”017055″,”017056″,”017116″,”017319″,”017324”)

If any body know how to solve this issue in Laravel way he can also answer this question.

Edit: Adding Curl headers that is in postman curl 7 headers

Advertisement

Answer

I was having issue because of url that i was providing. I should avoid the spaces and replace them with %20 and commas (“) to %22 in the curl api

url should be like this: https://data.medicare.gov/resource/6jpm-sxkc.json?$where=provider_number%20in(%22017000%22,%22017037%22,%22017055%22,%22017056%22,%22017116%22,%22017319%22,%22017324%22)

In php way my curl will be like this:

JavaScript

GoodLuck

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