on ‎2023 Feb 23 5:59 PM
HI,
The same code is working fine in SAP WEB IDE. and I'm able to call it Fetch API with method Post Successfully.
Now I have deployed Fiori app from SAP WEB IDE to S4 Hana Cloud. Now Iam getting error for fetch API in console is
"SyntaxError: Unexpected token '<', "<html><hea"... is not valid JSON"
Network Tab Response in debugger mode is
<html><head><title>Error report</title></head><body><h1>HTTP Status 500 - An internal application error occurred.
Request: -------------------</h1></body></html>
Could you please let me know, same code working fine in SAP WEB IDE and but not working after deployed to S4 Hana cloud?
How to resolve this issue?
PFB ,
const perform3 = (x) => {
return fetch(api, {
method: 'post',
headers: {
"X-Requested-With": 'XMLHttpRequest',
"Content-Type": 'application/json',
"X-CSRF-Token": CSRFToken,
"Accept": 'application/json',
},
body: JSON.stringify(x)
})
.then((res) => res.json())
.then((data) => {
console.log("Success:", data);
MessageArray.push({
Data: data
})
.catch((error) => console.log(error))
}
Request clarification before answering.
Hi Madhava,
Are you sending the payload in XML format? Since you have defined the request header Content-Type as "application/json", it would expect the payload in json format and throw an error as soon as the XML payload begins with the opening tag "<".
Try changing the Content-Type header to "text/xml" instead if your payload is in XML format.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI
FYI
The same code is working fine in SAP WEB IDE. and I'm able to call it Fetch API with method Post Successfully.
Now I have deployed Fiori app from SAP WEB IDE to S4 Hana Cloud. Now Iam getting error for fetch API in console is
"SyntaxError: Unexpected token '<', "<html><hea"... is not valid JSON"
Also, I have sent data in json format. Still iam getting same error
Any way i have used APi in promises. Its working as expected.
| User | Count |
|---|---|
| 8 | |
| 8 | |
| 7 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.