Solved

Getting 400 response by running CURL examples

  • 14 September 2023
  • 1 reply
  • 42 views

Hi! I receive 400 response by running CURL examples from 

I didn’t change anything in the examples except for Authorization header.

I also tried other filter variants such as

```
“filter”: {}
```

or

```
“filter”: {“audience”:{“field”:”email”,”operator”:”exists”}}
```

and also got 400.

What could be wrong?

---

The script I run:

https://pastebin.com/8HDbyM5g
 

#!/bin/sh

 

curl --request POST \

--url https://api.customer.io/v1/exports/customers \

--header 'Authorization: Bearer MY_APP_API_TOKEN' \

--header 'content-type: application/json' \

--data '{"filters":{"and":[{"or":[{"segment":{"id":4}}],"not":{"and":[{"segment":{"id":4}}]},"segment":{"id":4},"attribute":{"field":"unsubscribed","operator":"eq","value":true}}]}}'

 

echo ""

icon

Best answer by michaelm 14 September 2023, 22:57

View original

1 reply

Badge

Hello Vladimir!

 

I noticed you had submitted a ticket to us as well and got a reply there, but just in case this helps anyone else. The documentation example is incorrect and we will work on getting that adjusted. it requires some additional open/closing curly braces in order to be correctly formatted:

Taking exactly what is in the curl example and adding in the missing bits, you would get:

{
"filter": {
"and": [
{
"or": [
{
"segment": {
"id": 4
}
}
]
},
{
"not": {
"and": [
{
"segment": {
"id": 4
}
}
]
}
},
{
"segment": {
"id": 4
}
},
{
"attribute": {
"field": "unsubscribed",
"operator": "eq",
"value": true
}
}
]
}
}

You could also use what is in the general payload example:

{
"filter":
{
"and": [
{
"segment":
{
"id": 4
}
},
{
"attribute":
{
"field": "likes_pizza",
"operator": "eq",
"value": true
}
}]
}
}

Hope that helps give you a few working examples so you can build out the search you want to use!

Reply