-1

I try to get data with libcurl in PHP and my query, value in query, contains query brackets

?conditions[prs_id]=7&conditions[date]=[2019-03-26 TO 2019-04-03]&page=1&limit=1

When I send this with Postman I get object, but with curl i get error 400 which says this is bad request. but with

?conditions[prs_id]=7&conditions[date]=2019-03-26

I get answer and requested objects. So The problem is with value with brackets [2019-03-26 TO 2019-04-03]

I tried with url encoding, changing brackets to url codes but it won't worked.

How to properly send this with libcurl in PHP? in Postman works

nicram
  • 353
  • 3
  • 7
  • 24

2 Answers2

0

Try using urlencode() function in the query. I am not sure it will work or not but you can give it a try

RAZIUL
  • 128
  • 2
  • 8
  • 1
    the problem with urlencode() was becuse I encoded full query and It didn't work. Now I encode only part of data `"%5B2019-03-26+TO+2019-04-03%5D"` and this work – nicram Apr 02 '19 at 09:39
0

Use this function to build query params in url http_build_query

Totoro
  • 1