【发布时间】:2021-08-16 11:21:50
【问题描述】:
如何发布 apim 开发者门户使用 rest api 调用抛出一个 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 命令一起使用的正确访问令牌应该是什么以及从哪里获取它?
方法-2
使用这个 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
我们如何发布 apim 开发人员门户使用 rest api 调用抛出一个 shell 脚本或这个 (https://github.com/Azure/api-management-developer-portal/tree/master/scripts.v3) nodejs repo 脚本。
谁能帮帮我
【问题讨论】:
标签: azure curl azure-api-management