Orchestrator POST AddQueueItem with VBA

Hi there!

I would like to make API calls with Excel VBA. I have authenticated successfully but I am not able to post any queue item to Orchestrator. Can you help me please?

Please find my code below (I replaced my auth details with some x):

    Sub authenticate()
        Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
        URL = "https://platform.uipath.com/api/account/authenticate"
        objHTTP.Open "POST", URL, False
        objHTTP.setRequestHeader "Content-type", "application/json"
        objHTTP.send "{""tenancyName"":""xxx"",""usernameOrEmailAddress"":""xxx"",""password"":""xxx""}"
        Dim openPos As Integer
        Dim closePos As Integer
        Dim midBit As String
        openPos = InStr(objHTTP.responseText, ":") + 1
        closePos = InStr(objHTTP.responseText, ",") - 1
        midBit = Mid(objHTTP.responseText, openPos + 1, closePos - openPos - 1)
        addQueueItem (midBit)
    End Sub

    Sub addQueueItem(authData)
        Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
        URL = "https://platform.uipath.com/odata/Queues/UiPathODataSvc.AddQueueItem"
        objHTTP.Open "POST", URL, False
        objHTTP.setRequestHeader "Content-type", "application/json"
        objHTTP.setRequestHeader "Bearer", "authData"
        objHTTP.send "{""itemData"":""{""Priority"":""High"",""DeferDate"":""2018-03-21T13:42:27.654Z"",""DueDate"":""2018-03-5T13:42:27.654Z"",""Name"":""DocQueue"",""SpecificContent"":""{""Email@odata.type"":""#String"",""Email"":""obrian@uipath.com"",""Name@odata.type"":""#String"",""Name"":""O'Brian""}""}""}"
        addQueueItem (objHTTP.responseText)
    End Sub

Thank you for your response!

1 Like

Hi again!

I just managed to do it, so if anyone needs it:

Sub authenticate()
    Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
    URL = "https://platform.uipath.com/api/account/authenticate"
    objHTTP.Open "POST", URL, False
    objHTTP.setRequestHeader "Content-type", "application/json"
    objHTTP.send "{""tenancyName"":""xxxx"",""usernameOrEmailAddress"":""xxxx"",""password"":""xxxx""}"
    Dim openPos As Integer
    Dim closePos As Integer
    Dim midBit As String
    openPos = InStr(objHTTP.responseText, ":") + 1
    closePos = InStr(objHTTP.responseText, ",") - 1
    midBit = Mid(objHTTP.responseText, openPos + 1, closePos - openPos - 1)
    addQueueItem (midBit)
End Sub

Sub addQueueItem(authData)
    Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
    URL = "https://platform.uipath.com/odata/Queues/UiPathODataSvc.AddQueueItem"
    objHTTP.Open "POST", URL, False
    objHTTP.setRequestHeader "Content-type", "application/json"
    objHTTP.setRequestHeader "Authorization", "Bearer " & authData
    objHTTP.send "{""itemData"":{""Priority"":""High"",""Name"":""xxxx"",""SpecificContent"":{""Email@odata.type"":""#String"",""Email"":""obrian@uipath.com"",""Name@odata.type"":""#String"",""Name"":""O'Brian""}}}"
    MsgBox objHTTP.responseText
End Sub
7 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.