Recherches récentes


Pas de recherche récente

ZAF request proxy can send form data?

Avec réponse


Publication le 05 oct. 2021

I'd like to send form data from ZAF client using proxy.

I want to do like this.

curl -X POST "https://external.server/" -H "X-API-Key: ..." -H "Content-Type: application/x-www-form-urlencoded" -d 'test=1234'

but, if I do the following code, the parameter was converted to query string.

var options = {
url: "https://external.server/",
method: 'POST',
secure: true,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-API-Key': '{{setting.api_key}}'
},
data: "test=1234"
};
client.request(options);

The actual network request on browser had weird parameter.

POST https://mydomain.zendesk.com/proxy/v2/apps/secure/https://external.server/?0=t&1=e&2=s&3=t&4==&5=1&6=2&7=3&8=4

How is it possible?

 


1

4

4 commentaire

Hello Megumi,

Could you please specify the content type in contentType: 'application/x-www-form-urlencoded', instead of headers?

If it doesn't help, could you share more info from the Network tab about this request? Maybe it would help find out the issue. Because I think we can use form data in the ZAF request proxy.

0


Thanks Andriy,

I changed content type to contentType in param, but it doesn't help. Failed in the same result.

var options = {
url: "https://d856-2409-11-4260-bd00-7deb-ca46-32cb-c21f.ngrok.io/",
method: 'POST',
secure: true,
contentType: 'application/x-www-form-urlencoded',
headers: {
'X-API-Key': '{{setting.api_key}}'
},
data: "test=1234"
};
client.request(options);

Network tab is below.

Address and response header. The decoded url is "https://con-eclect-nakamura.zendesk.com/proxy/v2/apps/secure/https://d856-2409-11-4260-bd00-7deb-ca46-32cb-c21f.ngrok.io/?0=t&1=e&2=s&3=t&4==&5=1&6=2&7=3&8=4".

Request header:

 

Could you find something wrong?

0


Hello Megumi,

I think the issue is in method:"POST". IT should be type: "POST" instead.

var options = {
url: "https://d856-2409-11-4260-bd00-7deb-ca46-32cb-c21f.ngrok.io/",
type: 'POST',
secure: true,
contentType: 'application/x-www-form-urlencoded',
headers: {
'X-API-Key': '{{setting.api_key}}'
},
data: "test=1234"
};
client.request(options);

0


Hello Andriy, Thank you very much!

I could send the request!! Thanks!!

0


Vous devez vous connecter pour laisser un commentaire.

Vous ne trouvez pas ce que vous cherchez ?

Nouvelle publication