Skip to main content
Solved

Getting 400 response by running CURL examples

  • 14 September 2023
  • 1 reply
  • 66 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 ""

Best answer by michaelm

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!

View original
Did this topic help you find an answer to your question?

michaelm

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings