Skip to content

Using R for cURL commands,Message-ID:

1 message · Terry Therneau

#
On 04/02/2016 05:00 AM, r-help-request at r-project.org wrote:
-----------------
These are lines snipped from a working application.  I make use of the httr package.  The 
parameters of the call are assembled as a nested list "xlist" prior to this section.  The 
set of errors I check for is unique to the API I'm talking to, an internal one that's a 
bit odd in its return codes, but still it gives you the idea.

     auth <- authenticate(id$lanid, id$password, type="basic")
     query <- POST(url=control$posturl, body= xlist, auth, encode="json")

     if (status_code(query) >= 300) handle_reset(control$posturl)
     if (status_code(query) == 401)
             stop("invalid lanid/password for this application")
     else if (status_code(query) == 400)
              stop("internal error from dart package: 'syntax of request'")
     else stop_for_status(query)  #other query errors, e.g. server down