Start a Conversation

This post is more than 5 years old

Solved!

Go to Solution

2155

June 11th, 2015 00:00

How to use REST API

I build ScaleIO REST Client.

I succeed  login using "/api/login"parameter,and the login returns token(key) "xxxxx" .

C# code "HTTP Basic authentication"

--

string authInfo = @"admin:password";

authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));

request.Headers["Authorization"] = "Basic " + authInfo;

--

but,I don't know use token(key) "xxxxx".

For example,when I  invoke  HTTP GET request using "/api/instances/"parameter,

returns authentication erorr(401) at System.Net.WebException.

C# code

--

reqest.Headers["-Auth-Tken"] = "xxxxx";  // "xxxxx" is access_token.

--

1 Rookie

 • 

40 Posts

June 11th, 2015 09:00

For all sub-sequence API calls, you just need to pass the token without username in base64 encode to the request header. So something like this:

string authToken = @":token";

authToken = Convert.ToBase64String(Encoding.Default.GetBytes(authToken));

(I'm not C# expert)

19 Posts

June 11th, 2015 05:00

Did you insure the following:

Gateway service is running

The password was set in the  gatewayUser.properties file

1 Rookie

 • 

4 Posts

June 14th, 2015 21:00

I did as you described,it works.

Thank you!!

No Events found!

Top