cancel
Showing results for 
Search instead for 
Did you mean: 

Consumption of odata service through mbo

Former Member
0 Kudos

hi,

i m trying to consume odata service through mbo following the guide (http://scn.sap.com/docs/DOC-33172/diff?secondVersionNumber=4), but i am getting an error while testing the service in preview  as "The request URI is not valid. The segment 'EmployeeSet' refers to an entity set and not to a single entity'".

thanks

Accepted Solutions (0)

Answers (2)

Answers (2)

AshwinDutt
Active Contributor
0 Kudos

Hello Das,

Its not advised to disable the CSRF Token and fire ur modifying requests.

Use ur metadata URL of ur service and fetch the token by adding the header x-csrf-token - fetch.

U will get the token value in the response header and use that value when u fire ur Update Operation with the header x-csrf-token - <fetched_value>

However u can disable as specified below :

Cross-Site Request Forgery Protection - SAP NetWeaver Gateway Foundation (SAP_GWFND) - SAP Library

Regards,

Ashwin

Former Member
0 Kudos

hi Ashwin,

i am not able to create mbo by giving the value of CSRF token which i have fetched from rest client's response. can you help me out with that.

the service is same

http://devgw.ltisap.com:8005/sap/opu/odata/sap/ZEXP_REQ_SRV/EXPREQ_SET

Thanks.

AshwinDutt
Active Contributor
0 Kudos

Hello Das,

U cannot use a token that way. Fetching from a REST Client and using it somewhere. It wont work that way.

It works only when u fetch token from rest client and use it there only to test ur UPDATE operation.

Please check this.

Regards,

Ashwin

Former Member
0 Kudos

hi Ashwin,

do i have to change http method as post in creation of mbo for  odata service of update operation?

Because, i f i follow the same get method there will be no diff btw get and update .

Thanks,

Chayanica Das

AshwinDutt
Active Contributor
0 Kudos

Hello Das,

Yes u need to use HTTP Method PUT for Update Operation.

REgards,

Ashwin

Former Member
0 Kudos

hi,

but then it gives me CSRF  token validation failure.

how should i solve it?

Thanks,

Chayanica Das

AshwinDutt
Active Contributor
0 Kudos

Hello Das,

I do not have knowledge on how u can create an MBO that uses GW Services.

All i can try is to give u info regarding what all is required to fire ur GW Service.

Use the below URL and fetch the CSRF Token.

Add header x-csrf-token : fetch

Use HTTP Method GET.

http://devgw.ltisap.com:8005/sap/opu/odata/sap/ZEXP_REQ_SRV/$metadata

U will get the token value in the response header.

Now use that value in x-csrf-token header and fire ur UPDATE service with the HTTP Method PUT.

The data which u would like to update will go as part of ur payload.

Regards,

Ashwin

AshwinDutt
Active Contributor
0 Kudos

Hello Das,

Can u please share the url which u r using ? Please cross check the url again.

U need to send the EntitySet name in the URL not the Entity name.

https://xxxxx/sap/opu/odata/sap/DEMO_SRV/EmpEntitySet

Here EmpEntitySet is a Entity Set name. This is how u need to address ur GW service.

Please check this.

Regards,

Ashwin

Former Member
0 Kudos

http://devgw.ltisap.com:8005/sap/opu/odata/sap/ZODATA_HWCMBO_SRV/EmployeeSet%28%27000000009%27%29


i think i m using the entity set name only. which is EmployeeSet .

AshwinDutt
Active Contributor
0 Kudos

Please fire as below.

If its a QUERY ->

http://devgw.ltisap.com:8005/sap/opu/odata/sap/ZODATA_HWCMBO_SRV/EmployeeSet?$filter=<property_name>; eq '000000009'


If its a READ ->

http://devgw.ltisap.com:8005/sap/opu/odata/sap/ZODATA_HWCMBO_SRV/EmployeeSet(<property_name>='000000...


Where <property_name> is the name which u would have defined/maintained in ur GW model for the Employee Number.

Former Member
0 Kudos

hi,

i am not able to put any input parameter . It is giving me above mentioned error.

That is why i  have created a new service which gives only one parameter as output and takes no input.

but still it is not working. Can you help me out with this.

new service (http://devgw.ltisap.com:8005/sap/opu/odata/sap/ZODATA_HWCMBO_SRV/EmployeeSet)

AshwinDutt
Active Contributor
0 Kudos

Hello Das,

Its very strange that ur not able to put any parameter as input. It make no sense if u r not able to send any input.

The URL's which i shared are the standard GW URL's and it should work.

Can u try as below :

http://devgw.ltisap.com:8005/sap/opu/odata/sap/ZODATA_HWCMBO_SRV/EmployeeSet?$top=1

Regards,

Ashwin

Former Member
0 Kudos

hi Ashwin,

i am able to consume the following oData service according to the steps mentioned in the document. i have consumed it by get method.

http://devgw.ltisap.com:8005/sap/opu/odata/sap/ZEXP_REQ_SRV/EXPREQ_SET

Right now i m trying to consume one oData service for update  through mbo. Do you have any document for that?

AshwinDutt
Active Contributor
0 Kudos

Hello Das,

Please find the below for ur reference :

Here u will get all the basic info how ur payload has to be formed for ur Create Update & Delete operations.

Regards,

Ashwin

Former Member
0 Kudos

hi,

actually i have already created Odata for update. i m not able to consume it through mbo.

when i m trying with  post method , i am getting (CSRF validation failure) error, which i am not able to disable.

Thanks,

Chayanica Das.