Error: "Error while submitting the templates" While Requesting API

Hello,

I am trying to send a post request using the Request API to our custom Middleware API. When I do I receive a response with a 400 error “Error while substituting the templates”.

I have tried all the possible solutions found in the community but still getting the same response

Code Snippet

 var headers = {
                "Authorization": 'Bearer <%= access_token %>',
                "Content-Type": "application/json"
            };
            
            var options = { headers: headers, body: JSON.stringify(user), isOAuth : true };

            var url = MIDDLEWARE_URL + "/addUser";
           
            client.request.post(url, options)
            .then(
             function (response) {console.log(response)}
             , err => console.log(err))

Any advice would be greatly appreciated

Thank You.

Hi Hassan,

Can you just try this and let me know if it works?

let url = MIDDLEWARE_URL + "/addUser";

let response = await client.request.post(url,{
headers: { Authorization: "Bearer <%= access_token %>", "Content-Type": "application/json"},
body: JSON.stringify(user),
isOAuth: true
});

console.log(response);

No, it is not working after adding await in the response

But I found a solution

I am passing one of the access_token in body object using secure params <%= access_token %>
but now after updating the the platform-version this is not acceptable so we can not use secure params in body object while requesting any API

Thanks

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.