on 01-03-2014 10:12 PM
Hi All,
I am aware with SAP Gateway service we can send and receive data in XML format.. Just curious to know if we can receive request with data in Json format and process it in ECC...
Our front end application is using Json format and we are checking if can process request in same format in ECC or we need to transform it to XML before sending request to ECC. .
Please advice
Regards,
Rajesh
Rajesh,
json is very much supported for request body as well. Check this.
http://scn.sap.com/community/mobile/blog/2013/04/15/json-post-put-on-gateway
Note the Content-Type header.
Regards
Krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Krishna,
I followed the document but I am getting following error:
<?xml version="1.0" encoding="utf-8" ?>
</innererror>
</error>
In request header i have set Content-Type = application/json; charset=utf-8.. Any suggestions to follow..
Thanks
Hi Binson,
We are trying to get request in Json format with multiple line items using deep entity method.. its working for XML...
URI for GET Request:
/sap/opu/odata/sap/ZPA_TIMESHEET_SRV/Emp_Headers(Pernr='00000016',Fromdate=datetime'2013-01-01T00%3A00%3A00',Todate=datetime'2013-12-29T00%3A00%3A00',Profile='Z_TE01')?$expand=Emp_Times&$format=json
and we are using response body as request by clicking button "Use as Request"
Following is the screen shot after trying to post the request:
Please advice..
Thanks
Hi Rajesh,
Your request JSON body text is NOT correct. The request body should not have below text for deep entity:-
{"results":
So, please remove text :-
{"results":
and corresponding closing bracket.
}
Please check below link for more details :-
http://scn.sap.com/message/14659195#14659195
Regards,
Binson
Hi Binson,
I have done as you suggested.. any how its still not working and giving same error.. I am sharing the payload with you.. If you can point out and correct. I have added my comments on rows which I have removed..
{
"d" : {
"__metadata" : {
"id" : "http://<**********>/sap/opu/odata/sap/ZPA_TIMESHEET_T_SRV/Emp_Headers(Pernr='00000016',Fromdate=datetime'2013-12-24T00%3A00%3A00',Todate=datetime'2013-12-29T00%3A00%3A00',Profile='Z_TE01')",
"uri" : "http://<**********>/sap/opu/odata/sap/ZPA_TIMESHEET_T_SRV/Emp_Headers(Pernr='00000016',Fromdate=datetime'2013-12-24T00%3A00%3A00',Todate=datetime'2013-12-29T00%3A00%3A00',Profile='Z_TE01')",
"type" : "ZPA_TIMESHEET_T_SRV.Emp_Header",
"properties" : {
"Emp_Times" : {
"associationuri" : "http://<**********>/sap/opu/odata/sap/ZPA_TIMESHEET_T_SRV/Emp_Headers(Pernr='00000016',Fromdate=datetime'2013-12-24T00%3A00%3A00',Todate=datetime'2013-12-29T00%3A00%3A00',Profile='Z_TE01')/$links/Emp_Times"
}
}
},
"Pernr" : "00000016",
"Fromdate" : "\/Date(1387843200000)\/",
"Todate" : "\/Date(1388275200000)\/",
"Profile" : "Z_TE01",
"Emp_Times" :
**** Here I have removed the result { "results" :
[
{
"__metadata" : {
"id" : "http://<**********>/sap/opu/odata/sap/ZPA_TIMESHEET_T_SRV/Emp_Times(Counter='000000000588',Pernr='00000016',Profile='Z_TE01',Todate=datetime'2013-12-29T00%3A00%3A00',Fromdate=datetime'2013-12-24T00%3A00%3A00')",
"uri" : "http://<**********>/sap/opu/odata/sap/ZPA_TIMESHEET_T_SRV/Emp_Times(Counter='000000000588',Pernr='00000016',Profile='Z_TE01',Todate=datetime'2013-12-29T00%3A00%3A00',Fromdate=datetime'2013-12-24T00%3A00%3A00')",
"type" : "ZPA_TIMESHEET_T_SRV.Emp_Time",
"properties" : {
"Emp_Headers" : {
"associationuri" : "http://<**********>/sap/opu/odata/sap/ZPA_TIMESHEET_T_SRV/Emp_Times(Counter='000000000588',Pernr='00000016',Profile='Z_TE01',Todate=datetime'2013-12-29T00%3A00%3A00',Fromdate=datetime'2013-12-24T00%3A00%3A00')/$links/Emp_Headers"
}
}
},
"Counter" : "000000000588",
"Lstar" : "H11",
"Lstnr" : "",
"Rkostl" : "",
"Rproj" : "U-010000038.0010",
"Approved" : "",
"Awart" : "",
"Lgart" : "",
"Tasktype" : "",
"Status" : "40",
"Refcounter" : "",
"Reason" : "",
"Catshours" : "7.00",
"Catsamount" : "0.00",
"ZzworkLoc" : "WL01",
"Zzcreason" : "",
"ZzlabortypeDesc" : "",
"Action" : "",
"Pernr" : "00000016",
"Workdate" : "\/Date(1388016000000)\/",
"Skostl" : "C120699998",
"ZzLabortype" : "",
"ZzBillFlag" : "",
"ZzTask" : "",
"Profile" : "Z_TE01",
"Todate" : "\/Date(1388275200000)\/",
"Fromdate" : "\/Date(1387843200000)\/",
"Emp_Headers" : {
"__deferred" : {
"uri" : "http://<**********>/sap/opu/odata/sap/ZPA_TIMESHEET_T_SRV/Emp_Times(Counter='000000000588',Pernr='00000016',Profile='Z_TE01',Todate=datetime'2013-12-29T00%3A00%3A00',Fromdate=datetime'2013-12-24T00%3A00%3A00')/Emp_Headers"
}
}
}
]
}
}
} **** Also remove this for corresponding "results"
Thanks
You can create a POST JSON payload for yourself. If you run a read entity in GW_CLIENT with /sap/opu/odata/.../myservice/MyEntitySet(key)?$format=json, you will get the response in JSON.
Now if you click on the 'Use as Request' , you can get the request body for a POST on the left hand side of the GW_CLIENT
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.