Jump to content
jandings

AutoIt accesses REST-API of plan.io (Redmine)

Recommended Posts

jandings

Hello there,

and one more: how to access the REST-API of the project management system plan.io (which is based on Redmine), I'd like to share a few lines to make life easier for others.

With this you can access your plan.io data, reading and writing all kind of data. 

Replies are JSON style (though XML is possible, that's an option)

To work with JSON I usually depend on either just own AutoIt string operations or this AutoIt library, which I find best 11.2017:

; File        : Json.au3 (2015.01.08)
; Purpose    : A Non-Strict JavaScript Object Notation (JSON) Parser UDF
; Author    : Ward

$UserName="xxxxxx"                          ;plan.io credentials (usually e-mail address)
$PassWord="xxxx"                            ;plan.io credentials
$APIKey="xxxxxxxxxxxxxxx"                   ;This is the API Key from PlanIO, you can get it from the frontend, just google or ask plan.io help
$URL="xxxx.plan.io/"
$Command="issues.json?limit=50"             ;A list of commands and options is available through plan.io REST-API help

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET", "https://" & $URL & $Command &" X-Redmine-API-Key: " & $APIKey, False)
$oHTTP.SetCredentials($UserName, $PassWord, 0)
$oHTTP.Send()
$response = $oHTTP.ResponseText
ConsoleWrite ($response & @CRLF & @CRLF)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • jandings
      By jandings
      Hello there,
      since I spent some time to access the REST-API of the web shop system Shopware, I'd like to share a few lines to make life easier for others.
      With this you can access your Shopware database, reading and writing all kind of data. 
      Replies are JSON style.
      To work with JSON I usually depend on either just own AutoIt string operations or this AutoIt library:
      ; File        : Json.au3 (2015.01.08)
      ; Purpose    : A Non-Strict JavaScript Object Notation (JSON) Parser UDF
      ; Author    : Ward
      $UserName="xxxx" ;Shopware credentials of Shopware user who has the API checkbox ticked $PassWord="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ;API-Key of this user, NOT the Password $URL="www.XXX.com/api/" $Command="orders/64682?useNumberAsId=true" ;A list of commands and options is available through shopware REST-API help; Here we read order number 64682 $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "https://" & $URL & $Command , False) $oHTTP.SetCredentials($UserName, $PassWord, 0) $oHTTP.Send() $response = $oHTTP.ResponseText ConsoleWrite ($response & @CRLF & @CRLF)  
    • jandings
      By jandings
      Hello there,
      I'm trying to query a REST API of a webservice, SHOPWARE to be precise. The API is very well documented (https://developers.shopware.com/developers-guide/rest-api/#using-the-rest-api-in-your-own-a) but only using PHP. I tried some stuff but could not make it work.
      It should be very simple, because the following simply works in a Chrome-Browser:
      https://USERNAME:PASSPHRASE@www.SHOPWAREDOMAIN.com/api/orders/300
      queries me for username and passphrase and then dumps order number 300.
      Now I try to do the same in AutoIt (based on the wonderful work of many contributors here):
      #include-once #include "..\INCLUDE\winhttp.au3" #include "..\INCLUDE\OO_JSON.au3" ;Proxy Config Global $oJSON = _OO_JSON_Init() Global $obj = "" Global $sUserName = "USERNAME" Global $sPassword = "PASSPHRASE" Global $sDomain = "www.SHOPWAREDOMAIN.com/api/orders/300" Global $hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) JOC/0.1") ; without ie proxy settings $hConnect = _WinHttpConnect($hOpen, "https://" & $sDomain) ConsoleWrite ($hConnect & "#") $sReturned = _WinHttpSimpleSSLRequest($hConnect, "GET", $sUserName & ":" & $sPassword & "@" & $sDomain, Default ) ;$sReturned = _WinHttpSimpleSSLRequest($hConnect, "GET", $sDomain, Default, $sUserName & ":" & $sPassword) ;$sReturned = _WinHttpSimpleSSLRequest($hConnect, "GET", $sDomain, Default, , $sUserName & ":" & $sPassword ) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; See what's returned ConsoleWrite ($sReturned & "#" & @error) Whatever version I use (I tried the commented ones and many others), I always get a reply from Shopware:
      {"success":false,"message":"Invalid or missing auth"}
      At least this comes from Shopware. But there must be some format of the credentials that I don't know or understand.
      Any help?
    • JRSmile
      By JRSmile
      Hi there folks,
      every two years or so i have a new script for you...
      below you will find my approach to get some infos from the opsview.com rest api.
      i might extend this to a full software but for now here is the basic authentication and information gathering of hashtags proove of concept.
      you will need the winhttp.au3 and oo_json.au3 (use the forum search), additional thanks to trancexx for being awesome.
    • Tjalve
      By Tjalve
      Hello my fellow coders.
      At my company we have an installation of a BI-solution called QlikSense (next generation of Qlikview if anyonw knows about it). In Qliksense i have several tasks that extract data from varius sources and display them as graphs and tables on a dashboard. The entire system is based on websockets (im not 100% sure what websockets actually is though...).
      Anyways, I now have a need to externaly trigger theese reload tasks and this can be done using the QlikSense management API (http://help.qlik.com/sense/2.1/en-us/developer/#../Subsystems/RepositoryServiceAPI/Content/RepositoryServiceAPI/RepositoryServiceAPI-Connect-API.htm)
      This API uses REST to send commands and extract information from the Qliksense management console. Since i haven used this kind of API befor, im a bit lost but i have managed to create the following code: 
      $objHTTP = ObjCreate("winhttp.winhttprequest.5.1") $objHTTP.open ("GET", "http://localhost/qrs/user/count", False) $objHTTP.setRequestHeader ("Content-Type", "application/json") $objHTTP.setRequestHeader("Accept","application/json") $objHTTP.setRequestHeader("x-qlik-xrfkey","0123456789abcdef") $objHTTP.send() ConsoleWrite($objHTTP.responseText & @CRLF) This is supposed to return all the users of the Qliksense enviroment, in JSON format, but the only thing i get is a HTML-based code. If i save that to a html file, and open it, i get a logon page. So i guess there is a problem with authentication. I checked the examples in the API documentation and also the topping on authentication. It say that if the sender supports it, the system should uyse standard windows authentication without any need for username/password or certificates.
      If i just use the standard URL http://localhost/hub i get into the system withut logging on.
      ANY help would be appritiated. Perhaps someone understands the documentation better then I do?
×