This site is a testing version, but all data is shared with the live forum.


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

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Deathknife
Senior Member
Join Date: Aug 2014
Old 07-29-2017 , 08:52   Re: REST in Pawn - HTTP and JSON methodmaps
Reply With Quote #1

Quote:
Originally Posted by Drixevel View Post
Any chance of functions to iterate through objects and arrays?
You can already iterate through arrays. Although objects would be nice. smjansson extension allows you to.

PHP Code:
property int Length {
        public 
native get();

__________________
Deathknife is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 07-29-2017 , 11:22   Re: REST in Pawn - HTTP and JSON methodmaps
Reply With Quote #2

I intentionally left out object iteration to keep the code simple. Besides, when you're talking to an API you should know which fields are returned. If you're not talking to an API, I believe StringMap should suffice.

Quote:
Originally Posted by jdlovins View Post
Could i add you on steam DJ Tsunami?
I'm never on Steam anymore, but I'll try to be on IRC in the coming days. You can also create an issue on GitHub with screenshots and what not.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.

Last edited by DJ Tsunami; 07-29-2017 at 12:20.
DJ Tsunami is offline
milutinke
AlliedModders Donor
Join Date: Jun 2012
Location: Serbia
Old 07-30-2017 , 11:28   Re: REST in Pawn - HTTP and JSON methodmaps
Reply With Quote #3

Good job
milutinke is offline
Send a message via Skype™ to milutinke
Dreizehnt
Junior Member
Join Date: Jan 2016
Location: Russian Federation
Old 08-14-2017 , 12:18   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #4

Hi, I have a problem:
HTML Code:
L 08/14/2017 - 19:07:16: [RIPEXT] HTTP request failed: Error reading ca cert file /etc/ssl/certs/ca-certificates.crt - mbedTLS: (-0x3E00) PK - Read/write of file failed
Technical support for hosting where I rent the game server states that the extension visits the directories above the server folder and should not do this. How to be? And what actions are performed in the folder: /etc/ssl/certs/
__________________
Dreizehnt is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-14-2017 , 13:00   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #5

It's because SSL_CERT_FILE environment variable is set to that path (which your user doesn't have permission to read). I guess you are trying to access a HTTPS endpoint? However, I don't know a fix. I'm sure you could Google that errors because it's a cURL error, it doesn't come from the extension.
klippy is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 08-31-2017 , 03:57   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #6

Version 1.0.3 now comes with the CA bundle in the configs/ripext folder, instead of it being hardcoded to /etc/ssl/certs/ca-certificates.crt. This fixes the issue above and also allows you to replace it with your own CA bundle if your API isn't trusted.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.

Last edited by DJ Tsunami; 08-31-2017 at 04:02.
DJ Tsunami is offline
rio_
Junior Member
Join Date: Feb 2017
Old 09-02-2017 , 02:11   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #7

Is there no way to see if a key exists in a JSONObject? Even GetString produces an exception if the key doesn't exist, and only returns false if the key is set but is null. I feel like that's a huge piece that's missing... It shouldn't be up to the API you're communicating with to insert a null value for every possible key it could return.

Last edited by rio_; 09-02-2017 at 20:37.
rio_ is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 09-03-2017 , 05:42   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #8

Quote:
Originally Posted by rio_ View Post
It shoudn't be up to the API you're communicating with to insert a null value for every possible key it could return.
I agree, it shouldn't. You should know which fields are returned based on the API's documentation. And APIs should be versioned so that changes don't break existing calls.

Quote:
Originally Posted by asherkin View Post
errors should always be avoidable and thus always caused by programmer error (either due to misuse or missing checks).
I'm not sure what's considered "programmer error" in this case. If you pass an invalid index to an ADT array it throws an error, but if you pass an invalid key to an ADT trie it returns false. So the former is programmer error, but the latter is not?
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.

Last edited by DJ Tsunami; 09-04-2017 at 10:59.
DJ Tsunami is offline
splewis
Veteran Member
Join Date: Feb 2014
Location: United States
Old 09-04-2017 , 14:17   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #9

Quote:
Originally Posted by DJ Tsunami View Post
I'm not sure what's considered "programmer error" in this case. If you pass an invalid index to an ADT array it throws an error, but if you pass an invalid key to an ADT trie it returns false. So the former is programmer error, but the latter is not?
Given an arbitrary adt array it's possible to prevent going out of bounds with a Length check.

Given an arbitrary adt trie it's not possible to prevent a lookup to a non-existing key based on any check - thus the lookups need to be safe.

Even without that the lack of a "key existence check", most languages don't let you index to random parts of dynamic arrays (exception / undefined behavior), but most will let you attempt lookups to non-existent keys in maps.
__________________
splewis is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 09-04-2017 , 14:24   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #10

Quote:
Originally Posted by splewis View Post
Given an arbitrary adt array it's possible to prevent going out of bounds with a Length check.

Given an arbitrary adt trie it's not possible to prevent a lookup to a non-existing key based on any check - thus the lookups need to be safe.
This is exactly it.

(Yes, a KeyExists function and throwing on invalid keys would also be suitable for the error model, but you pay the hash and lookup penalty twice, so it is simpler in that case to do in one go.)
__________________
asherkin is offline
Reply



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 19:40.


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