0
votes

How to publish apim developer portal using rest api calls throw a shell script or using this repo https://github.com/Azure/api-management-developer-portal/tree/master/scripts.v3

enter image description here

Method-1

Got a hint from this link

 https://stackguides.com/questions/63796030/powershell-script-to-publish-apim-developer-portal

I tried with curl with the below request but was getting a 401 response.

 curl -v -X POST apim-instance1.developer.azure-api.net/publish -H "Authorization: SharedAccessSignature <SAS token> " -H "Content-Length: 0" 

Below is the response

*   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."}

What should be the right access token to use with this bash command and where to get it from?

Method-2

Using this repo https://github.com/Azure/api-management-developer-portal/tree/master/scripts.v3, passing required values and running ./generate.sh I get below error or response

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

How can we publish apim developer portal using rest api calls throw a shell script or this (https://github.com/Azure/api-management-developer-portal/tree/master/scripts.v3) nodejs repo scripts.

Can anyone help me over here

1

1 Answers