本文介绍了将.Net代码编译为Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们!..


我最近将我的手机与SureMDM集成,这是一个EMM软件。


API in他们的文档(http://mars.42gears.com/support/inout/mdm/api.html)使用.NET编写代码,而iam不熟悉.NET。 所以我不能继续我的开发。


他们的文档中的代码:

 使用 var  client = new  HttpClient ())
{
client.BaseAddress = new Uri (" HTTPS://suremdm.42gears.com/api");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue (" Basic",
转换 .ToBase64String(编码 .ASCII.GetBytes( String .Format(" {0}:{1}",username,password))));
client.DefaultRequestHeaders.TryAddWithoutValidation(" ApiKey",ApiKey);
//你的代码在这里
}

我在Postman ide中试过的代码


方法:获取


网址:  http://suremdm.42gears.com/api/location?DeviceID=rpr@gmail.com


DeviceId在params部分添加。


Headers:Content-type: application / json ApiKey:
Basic ***************


Iam geting
"用户名密码不匹配"错误回复 状态为401未经授权


所以有人可以说我在这里缺少什么吗?       我甚至尝试使用一些在线编译器编译,但我没有得到尊重的结果。  


提前致谢..




 

解决方案

hey guys!..

I am recently integrated my mobile with SureMDM which is an EMM software.

The API in their docs (http://mars.42gears.com/support/inout/mdm/api.html) having the code in .NET and iam not familiar with .NET.  so i cant proceed with my development.

code in their doc:

using (var client = new HttpClient())
{
	client.BaseAddress = new Uri("https://suremdm.42gears.com/api");
	client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
	Convert.ToBase64String(Encoding.ASCII.GetBytes(String.Format("{0}:{1}", username, password))));
	client.DefaultRequestHeaders.TryAddWithoutValidation("ApiKey", ApiKey);
	// your code goes here
}

my code which i tried in Postman ide

method : Get

URL : http://suremdm.42gears.com/api/location?DeviceID=rpr@gmail.com

DeviceId is added in params section.

Headers : Content-type :application/json ApiKey: Basic ***************

Iam geting"Username password does not match" error response with  status as 401 unauthorized

So can anyone say what iam missing here?       I even tried to compile with some online compiler but i dont get the respected result.  

Thanks in advance..

 

解决方案


这篇关于将.Net代码编译为Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 05:36
查看更多