2022 Nov 08 5:14 PM
Hi everyone,
I'm having troubles with sending a HTTP request (POST).
I'm creating a HTTP POST request from an URL with a query parameter. But when I send the request the target returns with the problem that the Query parameter is not set. This is the code:
lv_url = 'https://management.azure.com/subscriptions/blablabla/' &&
'resourcegroups/blablabla/providers/microsoft.datafactory/factories/blablabla/' &&
'pipelines/blablabla/createrun?api-version=2018-06-01'.
cl_http_client=>create_by_url(
EXPORTING
url = lv_url
IMPORTING
client = lo_http_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
others = 4
).
IF sy-subrc IS NOT INITIAL.
* Handle errors
ENDIF.
lo_http_client->request->set_method( 'POST' ).
lo_http_client->request->set_header_field( name = 'Content-Type' value = 'application/x-www-form-urlencoded').
CONCATENATE 'Bearer '
<l_token>
INTO lv_headerfield
SEPARATED BY space.
CALL METHOD lo_http_client->request->set_header_field
EXPORTING
name = 'Authorization' " Name of the header field
value = lv_headerfield. " HTTP header field value
CALL METHOD lo_http_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.
CALL METHOD lo_http_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.
IF sy-subrc NE 0.
CALL METHOD lo_http_client->get_last_error
IMPORTING
code = subrc
message = errortext.
WRITE: / 'communication_error( receive )',
/ 'code: ', subrc, 'message: ', errortext.
EXIT.
ELSE.
WRITE: / lv_url.
DATA(lv_string3) = lo_http_client->response->get_cdata( ).
WRITE: / lv_string3.
ENDIF.
This is the respons:
during the HTTP call the query parameter ?api-version=2018-06-01 is just not added.
Can someone help?
Regards,
Bastiaan
2022 Nov 08 6:03 PM
I'm surprised that the query parameter seems to not being sent...
Could you verify that the HTTP Trace confirms that it's sent or not sent? (SICF > Client > Recorder)
2022 Nov 08 9:31 PM
Hi,
I think I found the issue. It seems to be the length of the url. Accoring to SICF -> Client -> Recorder this request path is sent:
/subscriptions/0c73ca54-aadd-488f-85ee-3c72d2658fa4/resourcegroups/automation/providers/microsoft.datafactory/factories/plainwat
The request path is cut off on 128 charachters
Any idea how to fix this?
Bastiaan
2022 Nov 09 8:25 AM
Your URL is truncated.
Instead of:
DATA lv_url TYPE c LENGTH 128.
declare:
DATA lv_url TYPE string.
2022 Nov 09 9:31 AM
Hi,
lv_url is allready declared as string
Here you can see that the field is filled correctly:
Also when I look in the Object everything looks fine:
M_HOST = management.azure.com
M_PATH = /subscriptions/0c73ca54-aadd-488f-85ee-3c72d2658fa4/resourcegroups/Automation/providers/microsoft.datafactory/factories/plainwaterADF/pipelines/ExactOnline_MD/createrun
M_QUERY = api-version=20180601
When I look in the monitoring this URL is sent:
So during the push to the kernel: the url is truncated
regards,
Bastiaan
2022 Nov 09 2:18 PM
Weird. Just tried with my system. No issue, my HTTP trace shows that it transfers "?api-version=2018-06-01":
POST /subscriptions/blablabla/resourcegroups/blablabla/providers/microsoft.datafactory/factories/blablabla/pipelines/blablabla/createrun?api-version=2018-06-01 HTTP/1.0
2022 Nov 09 5:06 PM
It gets even weirder.....
I managed to use a way to shorten the URL, but that doesn't fix the issue...
He just does not sent the Query-parameters.
regards
2022 Nov 09 7:05 PM
Are you really sure that the ICF Client Recorder shows this?
POST /subscriptions/.../createrun HTTP/1.0
(without ?api-version=2018-06-01)
If so, you should check the SAP notes, and contact SAP Support.
2022 Nov 10 8:54 PM
This is what is shown in ICF monitoring
It seems like he puts the Query parameters in the header, instead of the URL
grt,
Bastiaan
2022 Nov 11 9:21 AM
That's only the path, not the query parameters. You must click the button display (glasses) > in external mode, and display the "request body". You will see POST ... HTTP/1.0 along with the query parameters (as in my previous comment).
2022 Nov 14 12:38 PM
Hi,
That is the problem.. I did all that but you only see this when I click at the glasses and click on Request Body:
if I do not pass the query parameters at all, then indeed I see this in the recorder, but offcourse I still need to pass the parameters:
Regards,
Bastiaan
2022 Nov 14 4:04 PM
In my test, I see the same as in your screenshot, but you don't show what is IMPORTANT (just before "HTTP/1.0", that we don't see in your screenshot). You should prefer pasting the text.