cfhttp curl and Zendesk API

243 Views Asked by At

I'm trying to authenticate with the Zendesk API using CF. I've been able to do it successfully via curl. Now I'm trying to figure out where to place the parameters using <cfhttp> so I can authenticate and create a user.

  curl -v -u [email protected]/token:************************* https://test.zendesk.com/api/v2/users.json \
    -H "Content-Type: application/json" -X POST -d '{"user": {"name": "Roger Wilco", "email": "[email protected]"}}'

I think my issue has to do with the placement of the user details to be authenticated against. As I'm not familiar with curl, I figured someone here might know which parameter type to apply it to.

<cfsavecontent variable="jsonString">
{"user": {"name": "Roger Wilco", "email": "[email protected]"}}
</cfsavecontent>
<cfhttp url="https://test.zendesk.com/api/v2/users.json" method="post">
<cfhttpparam type="header" name="Content-Type" value="application/json">
<cfhttpparam type="header" name="Accept" value="*/*">
<cfhttpparam type="header" name="-u" value="[email protected]/token:*************************">
<cfhttpparam type="body" value="#jsonString#">
</cfhttp>

Any tips on how I can position / where I position the variables so I can authenticate would be awesome.

Thanks in advance.

0

There are 0 best solutions below