Forum Discussion
Hey perk,
Sorry for the frustrating debugging. I'm able to reproduce the error in an endpoint as follows (will output ERROR with the error or SUCCESS with the content):
<#assign base = "https://domain.zendesk.com/api/v2/"/> <#assign url_getUser = base + "users?" + "query=email@domain.com"?url('UTF-8') /> <#assign response_user_no_json = http.client.request(url_getUser).get() /> <#if response_user_no_json.hasError> ERROR: ${response_user_no_json.error.message} <#else> SUCCESS: ${response_user_no_json.content} </#if>
In my case I am getting "ERROR: error making http request: Unsupported Media Type" which means that the zendesk service is rejecting the request for some reason.
I think DougS will be able to help you debug this further, but you may also want to check with Zendesk to figure out under what scenarios they send this error back.
Note: http.client only works in endpoints currently, but you can access endpoints directly via url by clicking the "View http Endpoint" button on the Endpoints screen
Hope this helps,
Yuri
Hi Yuri, thanks for your help. Are you adding the parameters Authorization: Bearer SOME_TOKEN_WE_HAVE to the request?
Can we add mulitple headers into the request? E.g. adding a "Content-type ?" It is strange though we will need a content-type set for a get request.
Interestingly the request works fine in curl
curl "https://domain.zendesk.com/api/v2/users?query=user@company.com" -H "Authorization: Bearer token" -v
which translates to:
> GET /api/v2/users?query=user@company.com HTTP/1.1
> User-Agent: curl/7.37.1
> Host: domain.zendesk.com
> Accept: */*
> Authorization: Bearer TOKEN
- perk10 years agoAdept
I added content type and I am getting success:
<#assign response_user_no_json = http.client.request(url_getUser).header("Authorization", "Bearer "+ response.content.access_token).header("Content-type", "application/json").json().get() />
- YuriK10 years agoKhoros ExpertGlad you were able to get to a solution! Sounds like Zendesk was expecting that header to be there.
Thank you,
Yuri
Related Content
- 5 years ago