0

When i try to filter posts based on the filter/keyword array the parameter is not found/NULL

curl -H "AUTHORIZATION: Bearer TOKEN" -X GET http://test.local:10088/posts -d "filter[keyword]=test" -v

The same request in a browser will return "test"

http://test.local:10088/posts?filter[keyword]=test

Any ideas what i'm doing wrong?

Sephen
  • 1,111
  • 3
  • 16
  • 38

2 Answers2

0

-d is for POST data. Yours is a GET, just add your "filter[keyword]=test" parameters as part of the URL without the -d parameter.

Also, just in case you are running into a character escaping problem with brackets and other chars, have a look at this: Passing a URL with brackets to curl

Community
  • 1
  • 1
jotadepicas
  • 2,389
  • 2
  • 26
  • 48
  • I already tried that and then the terminal only displays a ">" – Sephen Feb 13 '16 at 13:17
  • I suspect that could be because you need to escape the [ and ] from the command line and perhaps the = as well. I'll try it later but I comment so you can look into it too. – jotadepicas Feb 13 '16 at 18:07
  • updated my answer to includd character-escaping info. – jotadepicas Feb 13 '16 at 18:12
  • 2
    Thanks! it was the escaping, the correct way = `curl -H "AUTHORIZATION: Bearer TOKEN" -X GET http://test.local:10088/posts?filter\[keyword\]=test -v -g` – Sephen Feb 14 '16 at 08:23
0

Use quotes for URL:

curl -X GET "http://test.local:10088/posts?filter[keyword]=test"
sprutex
  • 980
  • 12
  • 12