通过Google App Script访问机器学习Web服务时获取错误401 [英] Get error 401 when accessing machine learning web service by Google App Script

查看:78
本文介绍了通过Google App Script访问机器学习Web服务时获取错误401的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


使用Google App Script(基于JavaScript)访问Azure机器学习网络服务时出现错误,它说:


{" error":{" code":" Unauthorized"," message":" Request is unauthorized to access resource。"," details":{{" code" :"ScoreRequestUnauthorized","message":"无效凭据
提供。""}]}}


我确定我的api密钥和网址是正确的。谁能告诉我哪里出错了? 非常感谢。


这是我的代码:        


  var url ='https://ussouthcentral.services.azureml.net/workspaces/ {my workspace id} /services/5ec815d52bf843d6b536eaa6049e47a2/execute?api-version=2.0&format=swagger'

  ; var api_key ='abc123' 

  var headers = {'Content-Type':'application / json','Authorization':('Bearer'+ api_key)}



  var data = {

    "输入":{

      " input1":$
      [

        {

          'col1':" value1",   

          'col2':" value2",    ...


        }¥b $ b      ],
    },b $ b    " GlobalParameters":  {

    }¥b $ b  }


  var options = {

    '方法':'发布',

    '标题':标题,

    'payload':JSON.stringify(data),

    'muteHttpExceptions':true

  }; b

  var request = UrlFetchApp.fetch(url,options);

  var responseCode = request.getResponseCode();

  var contentText = request.getContentText(" UTF-8");

  Logger.log(request.getHeaders()。toSource());

  Logger.log(responseCode)

  Logger.log(contentText)



Ps。我在微软机器学习博客上看过一篇由Raymond Laghaeian撰写的帖子  很有用。


该帖子的标题是"使用Azure ML" Google电子表格中的预测 "


但是,Github上的源代码链接无效现在。 =( 

解决方案

嗨Elisa,


请参阅有关如何获取的博文从Node.JS调用Azure机器学习Web服务:


https://blogs.msdn.microsoft.com/bigdatasupport/2016/02/18/how-to-call-a-azure -machine-learning-web-service-from-nodejs /



应该会有帮助。请告诉我们博客是否有用没有帮助。



问候,


Yutong



Hi,

I get an error when accessing Azure Machine Learning web service using Google App Script (it based on JavaScript), it says:

{"error":{"code":"Unauthorized","message":"Request is unauthorized to access resource.","details":[{"code":"ScoreRequestUnauthorized","message":"Invalid credentials provided."}]}}

I'm sure that my api key and url is correct. Can someone tell me where is wrong?  Thanks a lot.

Here is my code:     

  var url = 'https://ussouthcentral.services.azureml.net/workspaces/{my workspace id}/services/5ec815d52bf843d6b536eaa6049e47a2/execute?api-version=2.0&format=swagger'
  var api_key = 'abc123' 
  var headers = {'Content-Type':'application/json', 'Authorization':('Bearer '+ api_key)}

  var data = {
    "Inputs": {
      "input1":
      [
        {
          'col1': "value1",   
          'col2': "value2",   ...

        }
      ],
    },
    "GlobalParameters":  {
    }
  }

  var options = {
    'method' : 'post',
    'header': headers,
    'payload' : JSON.stringify(data),
    'muteHttpExceptions': true
  };

  var request = UrlFetchApp.fetch(url, options);
  var responseCode = request.getResponseCode();
  var contentText = request.getContentText("UTF-8");
  Logger.log(request.getHeaders().toSource());
  Logger.log(responseCode)
  Logger.log(contentText)

Ps. I've seen a post on Microsoft machine learning blog which was written by Raymond Laghaeian and it may be useful.

The title of that post is "Using Azure ML Predictions in Google Spreadsheet"

However, the link of the source code on Github is invalid now. =( 

解决方案

Hi Elisa,

Please see the blog post on how to call Azure Machine Learning Web Service from Node.JS:

https://blogs.msdn.microsoft.com/bigdatasupport/2016/02/18/how-to-call-a-azure-machine-learning-web-service-from-nodejs/

It should be helpful. Please tell us if the blog not help.

Regards,

Yutong


这篇关于通过Google App Script访问机器学习Web服务时获取错误401的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆