Select to view content in your preferred language

How i make an request sending an file end wating for response?

147
2
a month ago
Alex_matias
New Contributor II

Im trying to make an http request , using the example : 

function decodeVIN (VIN){

  // Output value. Initially set to an empty string (XLSForm null)

  let outValue = "";

  // Check the length to make sure a full VIN is provided

  if (VIN.length<11){

    return outValue;

  }

  // Add the VIN to the decode VIN API request

  let url = `https://vpic.nhtsa.dot.gov/api/vehicles/decodevinvalues/${VIN}?format=json`;

  // Create the request object

  let xhr = new XMLHttpRequest();

  // Make the request. Note the 3rd parameter, which makes this a synchronous request

  xhr.open("GET", url, false);

  xhr.send();

  if (xhr.status !== 200) {

    } else {

    outValue = xhr.responseText;

  }

return outValue;

}

But my i want to make an request that send an binary file in pdf end wait for a response.  Anyone know how to do that? 

0 Kudos
2 Replies
ZacharySutherby
Esri Regular Contributor

Hello @Alex_matias

Custom JavaScript functions in Survey123 don't support asynchronous calls nor does it support accessing local files. 

Thank you,
Zach
0 Kudos
jelisjack
New Contributor

To send a file and wait for a response, you can use a tool or script that supports asynchronous operations. For example, in Python, you could use the library to send the file and then wait for the response business. Ensure that your server or service handling the request is set up to handle file uploads and provide a response.

0 Kudos