yamachan1

updated

11 years ago

Y

yamachan1

1 Rookie

4 Posts

0

2184

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.

--

  • quanghoc

    2 Intern

    40 Posts

    1555

    0

    Posted 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)

  • chi_sox

    19 Posts

    1555

    0

    Posted June 11th, 2015 05:00

    Did you insure the following:

    Gateway service is running

    The password was set in the  gatewayUser.properties file

  • yamachan1

    1 Rookie

    4 Posts

    1557

    0

    Posted June 14th, 2015 21:00

    I did as you described,it works.

    Thank you!!