Authorization header in Restlet NetSuite web service call

流过昼夜 提交于 2019-12-12 06:24:01

问题


Trying to create test client for NetSuite Restlet web service.

Authorization header should look like:

{"Authorization":"NLAuth nlauth_account=5731597_SB1, nlauth_email=xxx@xx.com, nlauth_signature=Pswd1234567, nlauth_role=3","Content-Type":"application/json"}

Call with parameters should look like:

https://some.ns.restlet.uri&id=111&&amount=22

I do:

            WebRequestHandler handler = new WebRequestHandler();

            HttpClient client = new HttpClient(handler);
            var values = new Dictionary<string, string>
        {
                {"id", "111"},
                {"amount", "22"}
        };
            var content = new FormUrlEncodedContent(values);
            var uri = new Uri(@"https://some.ns.restlet.uri");

            content.Headers.Add(@"Authorization", Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes("NLAuth nlauth_account = 5731597_SB1, nlauth_email = xxx@xx.com, nlauth_signature = Pswd1234567, nlauth_role = 3")));
            content.Headers.Add(@"Content-Type", Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(@"application/json")));



            var response = await client.PostAsync(uri, content);
            var responseString = await response.Content.ReadAsStringAsync();

I got exception while adding first hader:

An exception of type 'System.InvalidOperationException' occurred in System.Net.Http.dll but was not handled in user code

来源:https://stackoverflow.com/questions/44310891/authorization-header-in-restlet-netsuite-web-service-call

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!