0

I'm using this AWS Object ApiRequest.

I've a url endpoint: url = "https://...com/songs"

NOT WORKING REQUEST(response 500):

ApiRequest request1 = new ApiRequest().withPath(url + "?userId=s123")
                    .withHttpMethod(HttpMethodName.GET);

WORKING REQUEST(response 200):

Map<String, String> mapParams = new HashMap<>();
mapParams.put("userId", "s123");

ApiRequest request1 = new ApiRequest().withPath(url)
                    .withHttpMethod(HttpMethodName.GET)
                    .withParameters(mapParams);

This is the ApiRequest object documentation:

https://docs.aws.amazon.com/AWSAndroidSDK/latest/javadoc/index.html?com/amazonaws/mobileconnectors/apigateway/ApiRequest.html

Why doesn't it work when using the userId in the query string(url) vs as a parameter? What is the difference between withParameters to query string?

Erez git
  • 73
  • 8

2 Answers2

2

Here userId is passed as a path variable

BASE_URL + "?userId=s123"

and Here userId is passed as a query parameter

mapParams.put("userId", "s123");

The path variable is not working because the API is designed to get params via query params not using path variables. They have mentioned function

withParameters(mapParams)

for accepting the params.

Eishon
  • 1,274
  • 1
  • 9
  • 17
1

Url params and query parameters are different. The query params are within the URL. HTTP Headers are NOT part of the URL. They're part of the HTTP Message. Maybe this could help;

What is the difference between HTTP parameters and HTTP headers?