question

Shuo C2 avatar image
0 Likes"
Shuo C2 asked Phil BoBo edited

Http.Request with query param laden url doesn't seem to send

I'm trying to send out a Http.Request (GET) with a url attached with query params.

I'm able to hit the server with the following (confirm by logs and a 502 response)

Http.Request request = Http.Request("example-api.com");
request.method = Http.Method.Get;
Http.Response response = request.sendAndWait();

However, when trying with the following

Http.Request request = Http.Request("example-api.com?param1=123");
request.method = Http.Method.Get;
Http.Response response = request.sendAndWait();
print(response.value);
print(response.statusCode);

The output console displays

(empty line here, code formatter deletes it if I leave it as empty line)
0

With logs on the server end showing the call didn't go through

Any ideas here?

FlexSim 21.0.0
flexsim 21.0.0https
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Phil BoBo avatar image
1 Like"
Phil BoBo answered Phil BoBo edited

The Http.Request() constructor that takes a URL doesn't parse out parameters. It only takes the protocol, host, port, and reference path. See FlexScript Class - Http.Request (flexsim.com)

Put the parameters into the data property. FlexScript Class - Http.Request (flexsim.com)

I'll add a case to the dev list to consider parsing the parameter data out of the URL in that constructor.

· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Shuo C2 avatar image Shuo C2 commented ·

hi Phil, thanks for the reply. Even if it does not parse out the params, will the request be sent as is, or will it just fail to send the request?

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Shuo C2 commented ·

Since you didn't specify a port or a path, that whole thing is being used as the host. "example-api.com?param1=123" instead of "example-api.com".

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.