cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP BPA Custom Script: Form data

shruti_chhabra
Explorer
0 Likes
89

Hi All,

I have an API call with form data. I am not able to pass the parameters correctly. Please suggest how to update the script? (I have masked url and password)

Following is my custom script

const options1 = {
    url: '<url>',
    method: 'POST',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
    },
    formData: {
    'username': 'auth_user',
    'password': '<password>'
    }
};
 

Accepted Solutions (1)

Accepted Solutions (1)

mvaibhav
Contributor
0 Likes

hi @shruti_chhabra 

Since your content type is url encoded in the request , you can't pass parameters as formData object. 

'Content-Type': 'application/x-www-form-urlencoded'
Instead, remove the formData property and build the request body as an URL-encoded string and pass it as a body tag in the request as shown below.

body: 'username=auth_user&password=' + encodeURIComponent('<password>')

Thanks,
Vaibhav


Answers (0)