View Single Post
BlackFart
Junior Member
Join Date: Feb 2021
Old 02-15-2021 , 09:20   Re: REST in Pawn 1.2 - HTTP client for JSON REST APIs (Updated 2021/02/07)
Reply With Quote #93

Quote:
Originally Posted by DJ Tsunami View Post
You are missing http:// in your URL.
I don't think this is the issue as I specified the port in the url

Quote:
Originally Posted by DJ Tsunami View Post
I would also check your sourcemod/logs folder for errors.
Nothing looks like linked to my issue (only info from maps etc)

Anyway, the extension is loaded correctly.
The plugin is listed loaded in the plugins list from sm too.
When I reload it I got prints next to the httpClient.`methode`("blabla", callBack)
But, I got no prints in the callback, even with this example :

I literally recreate a new plugin with the exact same code as your example (with just one more print) :
PHP Code:
#include <sourcemod>
#include <ripext>

HTTPClient httpClient;

public 
void OnPluginStart()
{
    
httpClient = new HTTPClient("https://jsonplaceholder.typicode.com");

    
httpClient.Get("todos/1"OnTodoReceived);
}

void OnTodoReceived(HTTPResponse responseany value)
{
    
PrintToServer("test please print");
    if (
response.Status != HTTPStatus_OK) {
        
// Failed to retrieve todo
        
return;
    }

    
// Indicate that the response is a JSON object
    
JSONObject todo view_as<JSONObject>(response.Data);

    
char todoTitle[256];
    
todo.GetString("title"todoTitlesizeof(todoTitle));

    
PrintToServer("Retrieved todo with title '%s'"todoTitle);

It's loaded correctly, and when I (re)load it, I still have no print from the callback

Last edited by BlackFart; 02-15-2021 at 09:21.
BlackFart is offline