azure - 如何使用 rest 命令或 shell 脚本或使用此 repo“api-management-developer-portal”发布 apim 开发人员门户
问题描述
如何使用rest api调用发布apim开发人员门户抛出一个shell脚本或使用这个repo https://github.com/Azure/api-management-developer-portal/tree/master/scripts.v3
方法一
从这个链接得到一个提示
https://stackoverflow.com/questions/63796030/powershell-script-to-publish-apim-developer-portal
我尝试使用 curl 进行以下请求,但收到 401 响应。
curl -v -X POST apim-instance1.developer.azure-api.net/publish -H "Authorization: SharedAccessSignature <SAS token> " -H "Content-Length: 0"
下面是回复
* Trying 52.224.143.217...
* TCP_NODELAY set
* Connected to apim-instance1.developer.azure-api.net (52.224.143.217) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: C=US; ST=WA; L=Redmond; O=Microsoft Corporation; CN=*.azure-api.net
* start date: May 27 03:02:35 2021 GMT
* expire date: May 22 03:02:35 2022 GMT
* subjectAltName: host "apim-instance1.developer.azure-api.net" matched cert's "*.developer.azure-api.net"
* issuer: C=US; O=Microsoft Corporation; CN=Microsoft Azure TLS Issuing CA 02
* SSL certificate verify ok.
> POST /publish HTTP/1.1
> Host: apim-instance1.developer.azure-api.net
> User-Agent: curl/7.58.0
> Accept: */*
> Authorization: SharedAccessSignature ?sv=2020-08-04&ss=bfqt&srt=sco&sp=rwdlacuptfx&se=2021-08-16T18:31:43Z&st=2021-08-16T10:31:43Z&spr=https&sig=DH24e2dYqDRJtpmTDI%2FkXGt2p3Gt1P33YFvIOPDasB8%3D
> Content-Length: 0
>
< HTTP/1.1 401 Unauthorized
< Keep-Alive: timeout=5
< Content-Type: application/json; charset=utf-8
< ETag: W/"61-pSa4Ze4sjk2JIS8YUgBXS7akHjk"
< X-Powered-By: Express
< X-Content-Type-Options: nosniff
< X-Frame-Options: sameorigin
< X-XSS-Protection: 1; mode=block
< Access-Control-Allow-Origin: *
< Strict-Transport-Security: max-age=31536000;includeSubDomains;
< Date: Mon, 16 Aug 2021 11:05:27 GMT
< Content-Length: 97
<
* Connection #0 to host apim-instance1.developer.azure-api.net left intact
{"code":"Unauthorized","message":"Please ensure that Authorization header contains valid token."}
与此 bash 命令一起使用的正确访问令牌应该是什么以及从哪里获取它?
方法二
使用这个 repo https://github.com/Azure/api-management-developer-portal/tree/master/scripts.v3,传递所需的值并运行 ./generate.sh 我得到以下错误或响应
Going to upload the content in /home/devops/Downloads/api-management-developer-portal/dist/snapshot.
Importing...
Unable to complete import. Unable to upload media files. mime.getType is not a function
我们如何使用 rest api 调用发布 apim 开发人员门户抛出一个 shell 脚本或这个 ( https://github.com/Azure/api-management-developer-portal/tree/master/scripts.v3 ) nodejs repo 脚本。
谁能在这里帮我
解决方案
推荐阅读
- node.js - 使用 Node 使用 RabbitMQ - 限制并行处理
- python - 无法在 Jupyter Notebook 中访问 Twitter API。如何解决身份验证问题?
- angularjs - 角度测试 - 在 Karma 上获取“TypeError:无法读取 null 的属性‘textContent’”
- python-2.7 - Firebase python - 如何检查文档中是否存在字段(属性)
- javascript - 如何使搜索过滤器对节点数组做出反应
- python - 使用 pandas,识别列之间的相似值
- java - Java Newb:递归循环后未重新分配返回参数
- wordpress - 按顺序列出城市
- c# - 如何在控件的不同区域显示不同的工具提示
- javascript - Jquery在视频上返回原始事件