Digital Exchange

last person joined: 4 hours ago 

This community is a place to discuss Blue Prism DX assets and development.

error 'The given key was not present in the dictionary' when trying to API HTTP request token with Blue Prism

  • 1.  error 'The given key was not present in the dictionary' when trying to API HTTP request token with Blue Prism

    Posted 09-19-2019 21:01

    Im trying to use the Blue Prism object HTTP request to get an access token for further processing the items. However, i couldn't manage to get the token due to the error 'The given key was not present in the dictionary'. I have looked all parameters and still didn't manage to solve the issue. I use a built in visual basic code to get the result as a collection which is later parsed to JSON to get the token.

    Output parameter Input parameter

    The underlying visual basic code is:

    
    If forcePreAuth Then
       'Sometimes a web server will require the authorisation header in the initial request
       'In which case we have to add the basic authorization header manually.
       Dim bytes() As Byte = System.Text.Encoding.UTF8.GetBytes(String.Format('{0}:{1}',username,password))
       Dim base64 As String = Convert.ToBase64String(bytes)
       request.Headers.Add('Authorization', 'Basic ' & base64)
    Else
      If Not String.IsNullOrEmpty(username) AndAlso Not String.IsNullOrEmpty(password) Then
        request.Credentials = New NetworkCredential(username,password)
      End If
    End If
    
    If useProxy Then
        Dim proxyURI As New Uri(proxyURL)
        Dim proxy As New WebProxy(proxyURI, True)
        Dim proxyCred As New NetworkCredential(proxyUsername, proxyPassword)
        Dim credCache As New CredentialCache()
        credCache.Add(proxyURI, 'Basic', proxyCred)
        proxy.UseDefaultCredentials = False
        proxy.Credentials = credCache
        request.Proxy = proxy
    End If
    
    request.Method = method
    request.ContentType = contentType
    
    Dim httpRequest As HttpWebRequest = TryCast(request, HttpWebRequest)
    If httpRequest IsNot Nothing Then
      If Not String.IsNullOrEmpty(accept) Then
        httpRequest.Accept = accept
      End If
      If Not String.IsNullOrEmpty(certID) Then
        httpRequest.ClientCertificates.Add(m_Certificates(certID))
      End If
    End If
    
    For Each r As DataRow In headers.Rows
        For Each c As DataColumn In headers.Columns
            Dim columnName As String = c.ColumnName
            Dim val As String = r(columnName).ToString
            request.Headers.Add(columnName,val)
        Next
        Exit For 'Only one row is allowed
    Next
    
    If Not String.IsNullOrEmpty(body) Then
      Dim requestStream As IO.Stream = request.GetRequestStream()
      Using sw As New IO.StreamWriter(requestStream, New Text.UTF8Encoding(False))
        sw.Write(body)
      End Using
    End If
    
    Using response As WebResponse = request.GetResponse()
      Dim responseStream As IO.Stream = response.GetResponseStream()
      Dim sr As New IO.StreamReader(responseStream)
      resultData = sr.ReadToEnd()
    End Using```
    
    
    
    
    
    --------------------------------------------------
    Disclaimer: This content was auto-posted from Stackoverflow. The original Stackoverflow question is here Stackoverflow Post, posted by ChenChela.


Welcome to the Blue Prism Digital Exchange Community!

The Blue Prism Digital Exchange is a "shop window" for new and emerging technologies—a platform that puts powerful RPA and AI capabilities into the hands of business leaders. Users can find and apply pre-built AI capabilities, in the form of downloadable integrations and Visual Business Objects (VBOs), to automated processes. These assets connect and integrate Digital Workers, existing systems and processes to Blue Prism's technology partners, creating a solid foundation of AI-enabled Intelligent Automation that's scalable and sustainable.

Blue Prism Digital ExchangeDX Asset IdeasContact DX Support

FAQs

The Blue Prism Digital Exchange (DX) is an online marketplace where businesses can instantly access, apply and share pre-built AI, cognitive and advanced RPA technologies from best-in-class providers. These assets easily connect to existing digital workers, systems and processes to enhance automation capabilities.
The Digital Exchange is free to all users. Most of the content on the DX is free to download but there are some submissions that do have a cost associated. The submissions with a cost are advertised on the asset card and profile. No unwanted costs will be applied to any users.
You can visit and browse the Digital Exchange here. If you would like to consume or download any material it is necessary to create an account on the Blue Prism Portal first.
Everyone can access the Digital Exchange and consume the assets on it. If you would like to contribute to the marketplace it is necessary that you create an account and sign up as a partner.