Skip to Content

Need help with Create/Update/Post of OData service

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>

Using ?sap-ds-debug=true gives me this error information: 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

1 method /IWCOR/IF_DS_EDM_SIMPLE_TYPE~TO_STRING. 2     DATA: 3       l_dsedx_date TYPE d, 4       l_dsedx_time TYPE t, 5       l_dsedx_days TYPE i, 6       l_dsedx_seconds TYPE p LENGTH 10 DECIMALS 0, 7       l_dsedx_milliseconds TYPE n LENGTH 3, 8       l_dsedx_length TYPE i, 9       l_dsedx_offset TYPE i. 10     FIELD-SYMBOLS: 11       <dsedx_p> TYPE p. 12  13     dsedx_initialize_descriptor io_element_descriptor lo_descriptor iv_value. 14  15     IF iv_kind = kind_json. 16       dsedx_format_datetime_json rv_value iv_value id_facets lo_descriptor. 17     ELSE. 
18       dsedx_format_datetime rv_value iv_value id_facets lo_descriptor. 
19       IF iv_kind = kind_uri. 20         to_uri_literal rv_value. 21       ENDIF. 22     ENDIF. 23 endmethod. 
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

1 method /IWCOR/IF_DS_EDM_SIMPLE_TYPE~TO_STRING. 2     DATA: 3       l_dsedx_date TYPE d, 4       l_dsedx_time TYPE t, 5       l_dsedx_days TYPE i, 6       l_dsedx_seconds TYPE p LENGTH 10 DECIMALS 0, 7       l_dsedx_milliseconds TYPE n LENGTH 3, 8       l_dsedx_length TYPE i, 9       l_dsedx_offset TYPE i. 10     FIELD-SYMBOLS: 11       <dsedx_p> TYPE p. 12  13     dsedx_initialize_descriptor io_element_descriptor lo_descriptor iv_value. 14  15     IF iv_kind = kind_json. 16       dsedx_format_datetime_json rv_value iv_value id_facets lo_descriptor. 17     ELSE. 
18       dsedx_format_datetime rv_value iv_value id_facets lo_descriptor. 
19       IF iv_kind = kind_uri. 20         to_uri_literal rv_value. 21       ENDIF. 22     ENDIF. 23 endmethod. 
An exception with the type CX_PARAMETER_INVALID_RANGE occurred, but was neither handled locally, nor declared in a RAISING clause

Exception CX_SY_NO_HANDLER occured in Class /IWFND/CL_SODATA_POST_PROC Method ABAP_KEY_TO_EDM and Line 1

1 METHOD abap_key_to_edm. 
2  3   DATA: lr_key     TYPE REF TO /iwfnd/if_mgw_core_types=>key_s, 4         lo_type    TYPE REF TO /iwcor/if_ds_edm_simple_type, 5         ls_key     TYPE /iwcor/if_ds_uri=>key_predicate_s, 6         lr_facets  TYPE REF TO /iwcor/if_ds_edm_element=>facets_s. 7  8   FIELD-SYMBOLS: <value>  TYPE data. 9  10   LOOP AT it_key REFERENCE INTO lr_key. 
In the context of Data Services an unknown internal server error occured

Exception /IWCOR/CX_DS_INTERNAL_ERROR occured in Program SAPMHTTP Include and Line -0

What does it mean?
Add comment
10|10000 characters needed characters exceeded

2 Answers

  • Best Answer
    Posted on Aug 29, 2013 at 02:22 PM

    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-netweaver-gateway-service-development for other issues.

    Thanks

    Krishna

    Add comment
    10|10000 characters needed characters exceeded

    • Thanks!

      It was exactly the case. My post was ok - but since I didn't write any code to the method it never returned anything.

      When I created the ABAP code everything worked as it should.

      Best regards,

      Kell Vagtholm

  • Posted on May 09, 2019 at 05:40 PM

    Thank you Krishna, a lot of time later it solve also my problem XD.

    Add comment
    10|10000 characters needed characters exceeded