on 08-29-2013 2:38 PM
Hi Experts
I created a service and got my GetEntitySet and GetEntity created and tested using the Gateway Client interface.
Now I want to create and test my Create/Update/Delete methods.
In Gateway Client I want to create a POST HTTP request, but I haven't been able to find any information on the format of the request and how to code my method in ABAP.
Please anyone if you will please enlighten me on this
Tried to read a lot of other posts on the forums, but haven't been able to figure out what the format should be.
Best regards.
Kell Vagtholm
When I use this code in my POST HTTP request:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<atom:content type="application/xml">
<m:properties>
<d:Username>KVA</d:Username>
<d:Lunchdate>2013-08-29T00:00:00</d:Lunchdate>
<d:Creaby>KVA</d:Creaby>
<d:Creadate>2013-08-29T00:00:00</d:Creadate>
<d:Idx>2</d:Idx>
<d:Noof>01</d:Noof>
</m:properties>
</atom:content>
</atom:entry>
I get an error message back:
<?xml version="1.0" encoding="utf-8" ?>
- <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code>005056A509B11ED1B9BF9F46AA8E82ED</code>
<message xml:lang="en">In the context of Data Services an unknown internal server error occured</message>
</error>
Header 1 |
---|
Value '00000000' violates facet information 'nullable=false' Exception /IWCOR/CX_DS_EDM_FACET_ERROR occured in Class /IWCOR/CL_DS_EDM_DATE_TIME Method /IWCOR/IF_DS_EDM_SIMPLE_TYPE~TO_STRING and Line 18
Parameter has invalid value: Parameter IV_VALUE has invalid value 00000000.Exception CX_PARAMETER_INVALID_RANGE occured in Class /IWCOR/CL_DS_EDM_DATE_TIME Method /IWCOR/IF_DS_EDM_SIMPLE_TYPE~TO_STRING and Line 18
An exception with the type CX_PARAMETER_INVALID_RANGE occurred, but was neither handled locally, nor declared in a RAISING clauseException CX_SY_NO_HANDLER occured in Class /IWFND/CL_SODATA_POST_PROC Method ABAP_KEY_TO_EDM and Line 1
In the context of Data Services an unknown internal server error occuredException /IWCOR/CX_DS_INTERNAL_ERROR occured in Program SAPMHTTP Include and Line -0 |
Hi Kell,
Your Post request body is right. There is no problem with that.
Problem seems to be with your date time values and their formats.
I would suggest you to go to your entity, mark all non-key parameters as nullable, Regenerate the runtime artefacts, Clear the cache and try again.
Logic behind this suggestion: Whenever there is a problem with formats like this, the conversion results in a null for that property. With the property marked as not nullable (default) it might throw an error like this.
Keep an eye on my blog http://scn.sap.com/community/netweaver-gateway/blog/2013/08/09/frequent-problems-encountered-in-netw... for other issues.
Thanks
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
Thanks for your response.
I thought that the post request body was ok - nice to get it confirmed.
When I check my service with GET $metadata i get this:
..
<Property Name="Creadate" Type="Edm.DateTime" Nullable="false" sap:label="Date" sap:sortable="false" sap:filterable="false" />
..
In the service builder my date fields are set to Nullable! (see attached photo)? I tried to delete the field and create it again - and after [Generate Runtime Objects] it still appear with Nullable="false" in $metadata.
Should the meatadata not hold property Updatable="false" and Deletable="false"?
Is there some way I can refresh the cache - that must be the problem.
Best regards,
Kell Vagtholm
Message was edited by: Kell Vagtholm Sorry - just read your post and found the cache transactions Thanks. But that did not solve the problem!
Hi Kell,
In this case for property 'Createdate' it should be Nullable = 'true'.
I think the class generation is not happening correctly. it would be good if you delete the generated classes and then regenerate the runtime classes once again.
Updatable="true" and Deletable="true" in your case. So it does not appear in the metadata document.Only the attributes with value equals to 'false' appear in metadata document.
Regards,
Atanu
Exactly - as i listed my metadata does not correspond with my property settings for the field creadate.
The metadata should list Updatable="false", Deletable="false", sap:sortable="false", and sap:filterable="false".
Which leads me to the question why not sap:updatable and sap:deletable?
How do I delete the auto generated classes? Think it will be easier to start all over and generate a new service from scratch. And check the metadata along the way before I do the ABAP coding.
Best regards,
Kell Vagtholm
Hi Krishna
I did run transactions on both systems, but still my metadata does not correspond with the properties.
I found two notes related to GW and metadata or regenration of objects, and asked our basis people to install them.
I hope when they are installed I can try and regenrate my service and it is ok then.
I will come back here with a response.
Thanks.
Best regards,
Kell Vagtholm
Hi Kell,
I think you will find the error is due to the fact that your POST body does not specify all of the properties, especially the key which is incomplete. The GW framework won't make these up.
I also have to say the key structure isn't great . Why not simply assign a guid key to the entity? The other properities can then be secondary indexes used for filtering.
Regards
RS
Hi Ron
Thanks for answer.
Do I have to specify all keys in the POST?
I thought that only the 'creatable' properties were supposed to be specified. My backend will take care of the rest. I only send what is absolutely the minimum in order to create my table entry in backend.
What if I discard some of the keys so that only my lunchdate and username is key? and omit the others as keys.
Would that help? I really only need those properties in backend in order to see when the records was created and by whom.
Best regards,
Kell Vagtholm
Hi Kell,
You can pretty much ignore the CRUD related fields because they do nothing in the backend. You can create a value in any property regardless of it being set to 'Createable'.
When you POST an entity, the server needs to know what the key (URI) of this resource is going to be unless it is a server-assigned address (in this case it is not, if it were a GUID, it would be). Not sending all key property values is breaking the rule and causing it to break during parsing. If you have values like 'userid', then yes the backend could use sy-uname and you don't need to send it, but you do need to have the property in the content list even if it is empty. The additional problem with date-time is that GW doesn't like properties of this type to be nulled unless it is set to 'is-nullable' (and why would you specify a key value that is going to be a null?).
The only time you don't need to send all properties is when you update with a PATCH operation.
Regards
Ron.
Hi Ron
This leads me back to the initial problem:
When I add all properties to my POST i get this error:
Value '00000000' violates facet information 'nullable=false'
Exception /IWCOR/CX_DS_EDM_FACET_ERROR occured in Class /IWCOR/CL_DS_EDM_DATE_TIME Method /IWCOR/IF_DS_EDM_SIMPLE_TYPE~TO_STRING and Line 18
From this request:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<atom:content type="application/xml">
<m:properties>
<d:Creadate>2013-08-29T12:00:00</d:Creadate>
<d:Creaby>KVA</d:Creaby>
<d:Lunchdate>2013-08-29T12:00:00</d:Lunchdate>
<d:Username>KVA</d:Username>
<d:Firstname>Kell</d:Firstname>
<d:Lastname>Vagtholm</d:Lastname>
<d:Idx>2</d:Idx>
<d:Noof>01</d:Noof>
</m:properties>
</atom:content>
</atom:entry>
All my properties have blank flag at the nullable.
Best regards,
Kell Vagtholm
Message was edited by: Kell Vagtholm I just created a variant - a new entity set where I don't have the first two fields and only my LUNCHDATE is a key. I created the methods and checked the service with GET and GET$metadata - all seems ok, When I post with all fields specified I get the same error - that my date (key field) is set to nullable="false". I just don't get it!? Best regards, Kell Vagtholm
Hi Kell,
This was nagging away at the back of my mind as it seemed to be a familiar issue, I've now figured out what is wrong.
There is nothing wrong with the latest POST body, the problem is in your ABAP.
In the create_entity method, there is an export parameter called er_entity. You must place the created properties back into this structure, as GW will then return this feed to the poster along with a success http status. If you fail to do this, and there is a non-nullable date, you get exactly the error you are having.
The problem is that the parser cannot parse the "output" because it's empty, the input is fine!
regards
Ron.
Thank you Krishna, a lot of time later it solve also my problem XD.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.