Question

Control HUB REST API for Authorization

  • 21 April 2022
  • 4 replies
  • 1930 views

I’m running below command in my windows machine for Auth token and getting below error message. 

curl -s -X POST -d '{"userName":"userid", "password": "password"}' https://cloud.streamsets.com/security/public-rest/v1/authentication/login -H "Content-Type:application/json" -H "X-Requested-By:SCH"

 

Invoke-WebRequest : Cannot bind parameter 'Headers'. Cannot convert the "Content-Type:application/json" value of type "System.String" to type "System.Collections.IDictionary".
At line:1 char:168
+ ... st/v1/authentication/login -H "Content-Type:application/json" -H "X-R ...
+                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

 

Can you please help? 

 


4 replies

Userlevel 3
Badge

This looks to be a PowerShell issue. See the following from Stack Overflow: https://stackoverflow.com/questions/45183355/invoke-webrequest-cannot-bind-parameter-headers

I was able to run with curl.exe in windows but I am not getting the response. 

Here the sample response. 

# Netscape HTTP Cookie File
# https://curl.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.

 

Userlevel 5
Badge

@dima 

Userlevel 3
Badge

Hi @sreenivasaraovaka 

Can you try below - it’s working for me. The token will be saved in file cookie.txt.

 

curl -X POST -d '{"userName":"userid", "password": "password"}' https://cloud.streamsets.com/security/public-rest/v1/authentication/login --header "Content-Type:application/json" --header "X-Requested-By:SCH" -c cookie.txt

Reply