Raised This Month: $51 Target: $400
 12% 

REST in Pawn 1.3 - HTTP client for JSON REST APIs (Updated 2021/08/22)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
BlackFart
Junior Member
Join Date: Feb 2021
Old 02-15-2021 , 07:40   Re: REST in Pawn 1.2 - HTTP client for JSON REST APIs (Updated 2021/02/07)
Reply With Quote #15

Thanks for your answer

Quote:
Mind if I ask, how are you recording your demos in JPEG?
For the example, I started to try to upload a file (in fact, it's not even a picture, it's just text) (in fact 2, I see no problem in saving demos with a different extension, it's just a headache to find your way around ha ha)

Quote:
But you're still trying to upload "data/image.jpg" file, which with the BuildPath / Path_SM one would be the file @ "addons/sourcemod/data/image.jpg"?

... Is there any file at all, with the path "addons/sourcemod/data/image.jpg"?
Yes, the file exists As a test, I ignore the demo file (and yes, there is one at least, so I go in the loop. Best debugger proof, my prints)

Quote:
In the end, with no errors, chances are the upload works just fine, and that it is your web url that may not work as expected.

... Is there anything running at all, on localhost, port 8080, and if so, what is the code over there?
No, it's not the right URL, but for the purpose of this post (in the forum, not http xD), I just changed the url (wouldn't be helping if I had wrote localhost:8081/api/v1/demo/upload)

And, I got nothing (my API is working well for other routes). If the route doesn't match, it would still be logged, as long as I hit localhost:8081

Here is the same code simplified :
Code:
HTTPClient httpClient;

public void UploadPicture()
{
    httpClient = new HTTPClient("localhost:8081/api/v1/demo/");

    char picturePath[PLATFORM_MAX_PATH];
    BuildPath(Path_SM, picturePath, sizeof(picturePath), "data/image.jpg"); 

    httpClient.UploadFile("upload", picturePath, OnPictureUploaded); 
}

void OnPictureUploaded(HTTPStatus status, any value)
{
    // never called
    if (status != HTTPStatus_OK) {
        PrintToServer("Noooooooooooooo %d", status);
        return;
    }
    PrintToServer("Upload complete");
}
But, as I said in the edit, even in the first example, where we get a simple json, it's not working. The callback is never called

Last edited by BlackFart; 02-15-2021 at 07:54.
BlackFart is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:10.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode