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.
what is that api? is api from your s4 hana cloud system?
can you show us the error in part?
<html><head><title>Error report</title></head><body><h1>HTTP Status 500 - An internal application error occurred.
Request: -------------------</h1></body></html>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Yes that API is to perform Goods Movement and SAP has design by default and it is standard API.
Thanks for the response.
Actually the error in cache part is - "SyntaxError: Unexpected token '<', "<html><hea"... is not valid JSON".
When i checked in console, In network tab status is "500" & Response is "<html><head><title>Error report</title></head><body><h1>HTTP Status 500 - An internal application error occurred.
Request: -------------------</h1></body></html> -> Inside the blank is request 123... and My webide server.
I haven't found any resolution to above error and not fixed. Now i removed fetch API and calling API inside Promise. Now its working fine.
| User | Count |
|---|---|
| 8 | |
| 8 | |
| 7 | |
| 4 | |
| 3 | |
| 2 | |
| 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.