我有servicestack
并使用Restfull和Authenticate
。
当我使用Dart
对此代码进行身份验证时:
var request = new html.HttpRequest();
request.open('POST', "http://x.x.x.x:9998/auth/basic", async:false);
request.setRequestHeader("accept", "application/json");
request.setRequestHeader("content-type", "application/json");
request.setRequestHeader("authorization", "Basic YWRtaW46cGFzc3dvcmQ=");
request.send(null);
print(request.response); //OK -> Print {"SessionId":"1","UserName":"admin","ResponseStatus":{}}
...在我打电话给这项服务之前发生的事情:
request.open('GET', "http://x.x.x.x:9998/hello/everybody?format=json", async:false);
request.setRequestHeader("accept", "application/json");
request.setRequestHeader("content-type", "application/json");
request.setRequestHeader("authorization", "Basic YWRtaW46cGFzc3dvcmQ=");
request.send(null);
print(request.response);
...在request.send(null);
给我错误输出显示无法加载资源:服务器响应状态为401(未授权) http://x.x.x.x:9998/hello/everybody?format=json
...给我打印好的输出显示(request.response);
{“结果”:“你好,每个人”}
我的Dart代码有问题吗?这是正常的吗。