Recent searches
No recent searches
API request to External Service and Secure Settings - 422 Error
Posted Mar 20, 2025
Hello --
We're trying to implement an API call to an external service in a ticket sidebar app, following instructions here: https://developer.zendesk.com/documentation/apps/app-developer-guide/making-api-requests-from-a-zendesk-app/
We're getting a 422 error from the service when making the call. The data object we're sending is giving us the response we expect when sent through Postman, but our Zendesk app is not producing the same result.
I want to confirm that the proxy URL being generated I can see in the console is formatting correctly here (some googling is showing me that maybe the correct path should be different):
https://{our_subdomain}.zendesk.com/api/v2/zendesk_apps_proxy/proxy/apps/secure/https%3A%2F%2Fxyz-portal.abc.auth0.com%2Foauth%2Ftoken
Here is what our implementation looks like…
In the manifest.json
file:
{
"name": "Test App",
...
"requirements": {
"proxy": {
"outgoing": [
{
"name": "authToken",
"url": "https://xyz-portal.abc.auth0.com/oauth/token",
"headers": ["Content-Type"],
"method": "POST"
}
]
}
},
"parameters": [
{
"name": "clientId",
"type": "text",
"required": true,
"secure": true
},
{
"name": "clientSecret",
"type": "text",
"required": true,
"secure": true
}
],
...
}
In the stript.js
file:
const client = ZAFClient.init();
async function fetchAccessToken() {
const data = {
type: "service_account",
client_id: "{{setting.clientId}}",
client_secret: "{{setting.clientSecret}}",
audience: "https://random-audience-url",
grant_type: "client_credentials",
};
const options = {
url: "https://xyz-portal.abc.auth0.com/oauth/token",
type: "POST",
contentType: "application/json",
data: JSON.stringify({
url: "https://xyz-portal.abc.auth0.com/oauth/token",
method: "POST",
headers: JSON.stringify({"Content-Type": "application/json" }),
body: data,
}),
accepts: "application/json",
secure: true,
};
client.request(options).then(response => {
console.log("Access Token:", response.access_token);
}).catch(error => {
console.error("Error fetching access token:", error);
});
}
0
1 comment
Erica Girges
Are these requests being made locally or in production? If locally, could you also check and confirm whether you also get this error once the app is installed?
0
Sign in to leave a comment.