Topic
5 replies Latest Post - ‏2013-09-11T16:17:59Z by d.m.spice
nepomuk
nepomuk
108 Posts
ACCEPTED ANSWER

Pinned topic REST POST with no payload

‏2013-09-11T10:51:19Z |

Is it possible to process a POST url with no payload (message body) ? Datapower seems to assume that there is a message body, tries to parse it and fails.

Guy

  • kenhygh
    kenhygh
    1433 Posts
    ACCEPTED ANSWER

    Re: REST POST with no payload

    ‏2013-09-11T12:52:43Z  in response to nepomuk

    Guy,

    Go in to the Objects->Services-> MPGW -> your mpgw, and turn on 'Process Messages Whose Body Is Empty'

    • nepomuk
      nepomuk
      108 Posts
      ACCEPTED ANSWER

      Re: REST POST with no payload

      ‏2013-09-11T16:01:40Z  in response to kenhygh

      That is already turned on to force rhe rule to be executed for GETs

  • d.m.spice
    d.m.spice
    44 Posts
    ACCEPTED ANSWER

    Re: REST POST with no payload

    ‏2013-09-11T14:27:23Z  in response to nepomuk

    Out of curiosity, why would you send an empty payload to a POST?  The purpose of a REST POST is to post a resource to the server.  Is the contents of what you are posting all in post parameters?

    • nepomuk
      nepomuk
      108 Posts
      ACCEPTED ANSWER

      Re: REST POST with no payload

      ‏2013-09-11T16:05:16Z  in response to d.m.spice

      The designers have decided to put all the data needed in the URL, they now want to make it a PUT. The only way I can make a POST or PUT work with no message body is to set the request type to non-xml. I tried a PUT and datapower first complained that Content-Length was invalid, so I added Content-Length:0 and then it tried to parse non existant content.

      • d.m.spice
        d.m.spice
        44 Posts
        ACCEPTED ANSWER

        Re: REST POST with no payload

        ‏2013-09-11T16:17:59Z  in response to nepomuk

        Oh ok, seems like poor design to have everything in the URL, but that's just me :)  

        We have a generic MPG for all of our REST calls that accommodates empty and non-empty payloads.  You may also need to turn "Non-XML Processing" on for the rules in the policy.

        Also, this may be of some help - it aided us a while back - http://www-01.ibm.com/support/docview.wss?uid=swg21566838