Skip to main content
Solved

Correct Syntax For curl In Windows


Forum|alt.badge.img+2

Hello Community.

I’m trying to use curl in Windows to add to a list.

So far I have this working in a bat file.

For windows I worked out that the url needs to be in double quotes and the double quotes in the data need to be escaped with a back slash.

d:\powerbas\Epos\curl.exe -o d:\powerbas\Epos\curl_test.txt -H "Content-Type: application/json" -X POST "https://a.klaviyo.com/api/v2/list/TcrZhw/members?api_key=pk_xxx" -d " { \"profiles\": [ { \"email\": \"antonisklaviyo+test@gmail.com\" } ] } "

I want to include the title, first, last name, Organization and phone number. I tried to start with the organisation like this.

d:\powerbas\Epos\curl.exe -o d:\powerbas\Epos\curl_test.txt -H "Content-Type: application/json" -X POST "https://a.klaviyo.com/api/v2/list/TcrZhw/members?api_key=pk_xxxx" -d " { \"profiles\": [ { \"email\": \"antonisklaviyo+test@gmail.com\" } , { \"organization\": \"klaviyo\" }] } "

Returns the following message

{"detail":"email or phone number is a required field for each profile"}

 

Best answer by alex.hong

Hi there @djsuperstore,
 

Thanks for sharing with the Community. The first thing I would try when receiving that error is to adjust your call to this format:

{
"profiles": [
{
"email": "test@klaviyo.com",
"phone_number": "+12340000000",
"$first_name": "First",
"$last_name": "Last",
"$organization": "Org"
}
]
}

I also noticed that someone on the support team is in contact with you so I would check your emails for additional info from them.

 

Thank you,

Alex 

View original
Did this topic or the replies in the thread help you find an answer to your question?

2 replies

alex.hong
Forum|alt.badge.img+58
  • Klaviyo Alum
  • 1552 replies
  • Answer
  • June 13, 2022

Hi there @djsuperstore,
 

Thanks for sharing with the Community. The first thing I would try when receiving that error is to adjust your call to this format:

{
"profiles": [
{
"email": "test@klaviyo.com",
"phone_number": "+12340000000",
"$first_name": "First",
"$last_name": "Last",
"$organization": "Org"
}
]
}

I also noticed that someone on the support team is in contact with you so I would check your emails for additional info from them.

 

Thank you,

Alex 


Forum|alt.badge.img+2
  • Author
  • Contributor I
  • 1 reply
  • June 16, 2022

Thanks Alex, Was quite an easy one.


Reply