Skip to Content
0
Former Member
Oct 18, 2006 at 05:58 AM

Content-Type for POST request

3274 Views

Hi all again,

I am setting content-type in the header to "text/xml" yet when I do a POST sap sends as content-type

"application/x-www-form-urlencoded". Is there something else I need to set to make it post with text/xml ?

  cl_http_client=>create_by_url( EXPORTING url = url
                                           ssl_id = 'ANONYM'
                                 IMPORTING client = http_client ).
* create HTTP client object
*  cl_http_client=>create_by_destination( EXPORTING DESTINATION = 'ZTOLLREQUEST'
*                                 IMPORTING client = http_client ).
                                                                                * Set HTTP headers
  http_client->request->set_header_field( name = '~request_method'
  value = 'POST' ).
  http_client->request->set_header_field( name = 'Content-Type'
  value = 'text/xml' ).
*  http_client->request->set_header_field( name = 'Authorization'
*  value = auth_string ).
*  http_client->request->set_header_field( name = 'sap-password'
*  value = 'ymous' ).
                                                                                * Set payload
  http_client->request->set_cdata( xml_string ).
                                                                                * send and receive
  CALL METHOD http_client->send
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2.

regards

Allan