Raised This Month: $80 Target: $400
 20% 

REST in Pawn - Communicate with JSON REST APIs


Post New Thread Reply   
 
Thread Tools Display Modes
slekenda
New Member
Join Date: Aug 2017
Old 11-07-2017 , 10:39   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #41

Hello!

I'm having a problem with my Post command. My server gets the post JSON data, but the plugin won't execute the function after. I'm calling DoSomething() function in OnPluginStart(). My code:
PHP Code:
public void DoSomething(){
    
PrintToServer("We are in DoSomething");
    
httpClient = new HTTPClient("http://ip.to.my.server");

    
JSONObject port = new JSONObject();
    
port.SetInt("port"iPort);

    
httpClient.Post("api/get_postfromcsgoserver"portOnPortResponse);

    
PrintToServer("We are in DoSomething2");
    
delete port;

}

public 
void OnPortResponse(HTTPResponse responseany value){
    
PrintToServer("We are in OnPortResponse");
    if(
response.Status != HTTPStatus_Created) {
        
PrintToServer("!= HTTPStatus_Created");
        return;
    }
    if (
response.Data == null){
        
PrintToServer("response.data == null");
        return;
    }

The latter is just a part of the function. I don't get any compilation errors. It won't even print the "We are in OnPortResponse" to the server.

Does connection have to be https?

I get this from my server that the plugin tries to Post so it's working
[07/Nov/2017 14:28:09] "POST /api/get_postfromcsgoserver/ HTTP/1.1" 200 98

Thank you!

Last edited by slekenda; 11-07-2017 at 10:44.
slekenda is offline
ReymonARG
Junior Member
Join Date: Jun 2017
Old 11-07-2017 , 20:24   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #42

You need to turn off the invernation of the server, or enter to the server.

Quote:
Originally Posted by slekenda View Post
Hello!

I'm having a problem with my Post command. My server gets the post JSON data, but the plugin won't execute the function after. I'm calling DoSomething() function in OnPluginStart(). My code:
PHP Code:
public void DoSomething(){
    
PrintToServer("We are in DoSomething");
    
httpClient = new HTTPClient("http://ip.to.my.server");

    
JSONObject port = new JSONObject();
    
port.SetInt("port"iPort);

    
httpClient.Post("api/get_postfromcsgoserver"portOnPortResponse);

    
PrintToServer("We are in DoSomething2");
    
delete port;

}

public 
void OnPortResponse(HTTPResponse responseany value){
    
PrintToServer("We are in OnPortResponse");
    if(
response.Status != HTTPStatus_Created) {
        
PrintToServer("!= HTTPStatus_Created");
        return;
    }
    if (
response.Data == null){
        
PrintToServer("response.data == null");
        return;
    }

The latter is just a part of the function. I don't get any compilation errors. It won't even print the "We are in OnPortResponse" to the server.

Does connection have to be https?

I get this from my server that the plugin tries to Post so it's working
[07/Nov/2017 14:28:09] "POST /api/get_postfromcsgoserver/ HTTP/1.1" 200 98

Thank you!
ReymonARG is offline
Mitchell
~lick~
Join Date: Mar 2010
Location: noitacoL:
Old 11-08-2017 , 01:22   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #43

Quote:
Originally Posted by ReymonARG View Post
You need to turn off the invernation
I think you mean Hibernation.
__________________
Mitchell is offline
slekenda
New Member
Join Date: Aug 2017
Old 11-08-2017 , 04:12   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #44

Quote:
Originally Posted by ReymonARG View Post
You need to turn off the invernation of the server, or enter to the server.
Thank you! I have been wondering this now for a while. This was the problem, I never joined the server. And it's hibernation
slekenda is offline
ReymonARG
Junior Member
Join Date: Jun 2017
Old 11-08-2017 , 12:01   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #45

I Hope that plugin author change to server think and not the game frame
ReymonARG is offline
Reply


Thread Tools
Display Modes

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 07:31.


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