Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

API Restful - Get parameters passed into the url

massimo_sforza
Participant
0 Kudos

Hi,

sorry but I am a very novice in API rest.

I created a service that handle my Zclass that implement the interface IF_HTTP_EXTENSION and so the method HANDLE_REQUEST.

When my service is called with a method GET, some parameters are passed into the url. For example

http://my_address.net:8000/my_folder/get_something?sap-client=100&param1=12345678

I want to retrieve the value of parameter "param1"

I tried using the method "server->request->get_uri_parameter"   passing the name "param1" but no values return. I tried with some others methods but nothing. I can see that anything happen in debug...

How can i retrieve the parameter, or better, the list of parameters passed?

Thanks a lot

KR

Massimo

1 ACCEPTED SOLUTION

massimo_sforza
Participant

Hi Custodio,

thanks a lot for your fast reply.

Actually I had already tried the method server->request->get_form_fields() but the only parameter name that I have is "content", there is no "param1"... maybe they are passing me the parameters in a wrong way?

However Lucas thanks a lot for the link, it's always good have resources to improve my knowledge...

6 REPLIES 6

Former Member
0 Kudos

Check out this blog: - someone has already done exactly what you're trying to do. The code is available on github: cesar-sap/abap_fm_json · GitHub 

0 Kudos

Hi Lucas,

Although this is a very nice and well known project, and don't think this is "exactly" what Massimo needs.

Hi Massimo,

Please try method  server->request->get_form_fields( ), for all parameters, or server->request->get_form_field( ) for a single parameter. Yes, I know, its name is misleading, but should solve your problem.


Another way is to use  server->request->get_header_field( '~request_uri' ) and then split the values manually. First method would be easier though.

Cheers,

Custodio

0 Kudos

Haha well... He would have found his answer by reading that code.... I wasn't suggesting he use the project in its entirety.

massimo_sforza
Participant

Hi Custodio,

thanks a lot for your fast reply.

Actually I had already tried the method server->request->get_form_fields() but the only parameter name that I have is "content", there is no "param1"... maybe they are passing me the parameters in a wrong way?

However Lucas thanks a lot for the link, it's always good have resources to improve my knowledge...

0 Kudos

If the HTTP method is GET, surely you will have on the fields parameter everything after "?", in a name/value table.

Maybe they are using POST?

Cheers,

Custodio

0 Kudos

Hi Custodio,

your images let me speechless...

I'll speak with "the others".

Thanks a lot.

KR

Massimo