Restlet NetSuite Web服务调用中的授权标头

时间:2017-06-01 14:54:41

标签: c# netsuite

尝试为NetSuite Restlet Web服务创建测试客户端。

授权标题应如下所示:

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

使用参数调用应如下所示:

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

我做:

            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();

我在添加第一个黑客时遇到异常:

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

0 个答案:

没有答案
相关问题