ErikMinekus / sm-ripext

SourceMod REST in Pawn Extension
https://forums.alliedmods.net/showthread.php?t=298024
GNU General Public License v3.0
133 stars 38 forks source link

Failing request with formatted text #21

Closed RuzsaGergely closed 4 years ago

RuzsaGergely commented 4 years ago

For my API, I need to format the URL suffix in the requests because I read the parameters from a file (Like the number of the server). If I do format the suffix then for some reason, the request will fail. Example:

char url_sufix[512];
Format(url_sufix, sizeof(url_sufix), "/getTasks/%s", servernum);
httpClient.Get(url_sufix, OnJobReceived);

But If I write the exact string to it then it works. Example:

httpClient.Get("/getTasks/9", OnJobReceived);

The "servernum" variable is not empty for sure, because I can print to chat the "url_suffix" content and it works fine.

What can I do about it?

ErikMinekus commented 4 years ago

%s is for strings, you need %d for whole numbers. See https://wiki.alliedmods.net/Format_Class_Functions_(SourceMod_Scripting)#Format_Specifiers

RuzsaGergely commented 4 years ago

Yep, that was the issue. Thanks for the heads up!