Skip to Content
0

How to get input parameter for a create operation?

Jan 09, 2017 at 11:05 PM

229

avatar image
Former Member

Hi,


A create operation has been created for one of my service from the gateway service. However while I use $metadata option in the URL,
/sap/opu/odata/SAP/PRODUCT/<my service>/$metadata, I get the following errors:

the error is 'The request URI is not valid. The segment '<my service>' refers to an entity set and not to a single entity'

i have tried both 'GET' and 'POST' method, the same error was got.

the parameter $metadata does work for any services whose GetEntity or GetEntitySet operation has been implemented.

My question is, does option $metadata work for Create operation or not? if yes, how to form the URL? if not, how can the service consumer get the input parameter for Create operation?

thanks

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Krishna Kishor Kammaje
Feb 15, 2017 at 06:29 AM
0

'Create' is an HTTP POST operation. So all the properties of the entity will be used in the request body as a JSON object.

So do a $metadata on the service, and get to know all the properties of the entity. Next use them in the requets body.

Share
10 |10000 characters needed characters left characters exceeded
Krishna Kishor Kammaje
Jan 17, 2017 at 06:01 AM
0

$metadata is only for the service.

/sap/opu/odata/SAP/PRODUCT/$metadata

What are you expecting when you say "$metadata work for Create operation"?

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Feb 15, 2017 at 04:46 AM
0

Hi Krishna,

I want to get the parameter list of 'create' operation. thanks

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Feb 15, 2017 at 02:25 PM
0

Correctly said by Krishna.

If you have a deep insert, get a response with expanded entityset with "GetEntitySet". This should ideally give you all the parent as well as child entities. Now take one record with parent-child combination. Use the "Use as Request" option in the response to get the request you are going to post. Carefully remove the header information from the request and adjust the braces. Now do the Post operation to fill your data.

For create you won't get any such parameter list to monitor what all data need to be filled to create a record.

Share
10 |10000 characters needed characters left characters exceeded