Chuck,

I’m in the process of finishing REST calls to the Pressero web2print API.

The majority of the methods I had to write are quite similar and go something 
like this:

------------------------------------------------------------

ARRAY TEXT($aHeader_Name;0)
ARRAY TEXT($aHeader_Value;0)
APPEND TO ARRAY($aHeader_Name;"Content-Type")
APPEND TO ARRAY($aHeader_Value;"application/json; charset=utf-8")
APPEND TO ARRAY($aHeader_Name;"Authorization")
APPEND TO ARRAY($aHeader_Value;"token "+$token)

$oRequest:=OBJ_Create 
$oResponse:=OBJ_Create 

$URL:="https://admin.chi.v6.pressero.com/api/site 
<https://admin.chi.v6.pressero.com/api/site>/"+$siteDomain+"/users/"+$userGUID

$Status:=HTTP Request(HTTP get 
method;$url;$oRequest;$oResponse;$aHeader_Name;$aHeader_Value)

If ($status=200) //the status will be defined by your API…generally 200 or 201 
for a success, 400 range for a failure

   $oUser:=OB Copy($oResponse) //this obviously varies depending on your API

end if
——————————————————————————————

Things that I learned along the way:

1) The API should tell you which type of method to use in the HTTP Request 
command (GET / PUT / POST / etc)

2) The API will tell you what (if any) items need to go into the 2 header arrays

3) Sometimes the $oRequest or $oResponse is a JSON object, other times 1 or 
both are simply text. It will depend on their end.

4) Postman is a great application to use to figure out what you need to do: 
https://www.getpostman.com/apps <https://www.getpostman.com/apps>

it helps you construct the URL properly with the necessary parameters, as well 
as the things you would need to put into the
headers (the 2 arrays I set up above) or include in the parameters of the URL 
you’re sending

I can’t recommend the Postman app highly enough for this.

Happy to answer any questions on this.

HTH,
Randy

----------------------------------------------------------------------
Randy Jaynes
Senior Programmer and Customer Support

http://printpoint.com <http://printpoint.com/> • 845.687.3741 • PrintPoint, Inc 
• 57 Ludlow Lane • Palisades, NY 10964 
Please send all email contacts to supp...@printpoint.com 
<mailto:supp...@printpoint.com>






> On Dec 11, 2018, at 9:43 AM, Chuck Miller via 4D_Tech <4d_tech@lists.4d.com 
> <mailto:4d_tech@lists.4d.com>> wrote:
> 
> Hi all 
> 
> subj says it all. I may have to connect to a rest server and deliver a file 
> in that manner for one of my clients. As I have never used rest before, I was 
> hoping for an example of how that would be done. I looked on 4D web site and 
> in knowledge base but could not find what I was looking for. Any help 
> appreciated
> 
> Regards
> 
> Chuck
> ------------------------------------------------------------------------------------------------
> Chuck Miller Voice: (617) 739-0306
> Informed Solutions, Inc. Fax: (617) 232-1064       
> mailto:cjmiller<AT SIGN>informed-solutions.com 
> <http://informed-solutions.com/> 
> Brookline, MA 02446 USA Registered 4D Developer                
>       Providers of 4D and Sybase connectivity
>          http://www.informed-solutions.com 
> <http://www.informed-solutions.com/>  
> ------------------------------------------------------------------------------------------------
> This message and any attached documents contain information which may be 
> confidential, subject to privilege or exempt from disclosure under applicable 
> law.  These materials are intended only for the use of the intended 
> recipient. If you are not the intended recipient of this transmission, you 
> are hereby notified that any distribution, disclosure, printing, copying, 
> storage, modification or the taking of any action in reliance upon this 
> transmission is strictly prohibited.  Delivery of this message to any person 
> other than the intended recipient shall not compromise or waive such 
> confidentiality, privilege or exemption from disclosure as to this 
> communication. 
> 
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html 
> <http://lists.4d.com/archives.html>
> Options: https://lists.4d.com/mailman/options/4d_tech 
> <https://lists.4d.com/mailman/options/4d_tech>
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com 
> <mailto:4d_tech-unsubscr...@lists.4d.com>
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to