0

I am hitting admitAD API using curl command.

If i below URL

curl -L -H 'Authorization: Bearer MY_TOKEN' -X GET https://api.admitad.com/payments/?limit=2&has_statement=0

I am getting response

 {
    "_meta": {
        "count": 21,
        "limit": 2,
        "offset": 0
    },
    "results": [{},{}]
 }

But if i hit this URL , Notice URL enclosed in double quote

curl -L -H 'Authorization: Bearer MY_TOKEN' -X GET "https://api.admitad.com/payments/?limit=2&has_statement=0"

I am not able to get valid response

{
    "_meta": {
        "count": 0,
        "limit": 2,
        "offset": 0
    },
    "results": []
}

I even tried this in postman , But it is also giving invalid response

Please help

Ajit Soman
  • 113
  • 2
  • 8

1 Answers1

1

Without quotes, the & will cause everything before it to run in the background. Effectively making your command be:

curl -L -H 'Authorization: Bearer MY_TOKEN' -X GET https://api.admitad.com/payments/?limit=2

Followed by executing has_statement=0 as a separate (but valid) command.

With the quotes the & is escaped and the intended command is sent. Which apparently fails when it has the &has_statement=0 part. This is supported by the fact it fails with postman also.

Brandon Xavier
  • 2,022
  • 13
  • 15
  • Thanks , the `&` was causing this issue. I changed my complete URL to URL+ `?limit=${data.limit}'&'offset=${data.offset}'&'has_statement=${data.hasStatement}` with `&` enclosed with single quote `'&'` Fixed my issue – Ajit Soman Apr 11 '21 at 05:42