Upload swagger (json file) to an API using PAPI
search cancel

Upload swagger (json file) to an API using PAPI

book

Article ID: 206014

calendar_today

Updated On:

Products

CA API Developer Portal

Issue/Introduction

PAPI to upload swagger (json file) to an api (state incomplete) but it shows an error.

curl used

C:\GMU>curl -i -X POST -H "Content-Type:multipart/form-data" -H "Origin:https://apim.<tenant_domain>" -H "Authorization: Bearer xxxxxxxxxxxxxxxxxxx"  -F "files=@\"./myapi12.json\";filename=\"myapi12.json\"" "https://apim-ssg.<tenant_domain>:9443/tenant45/api-management/1.0/apis/f0484754-35c2-4b32-966a-723026c55b1e/assets" -k -v

Error

{"error":{"code":"ValidationException","message":{"lang":"en","value":"The request could not be completed due to data input errors."},"detail":{"errorCode":"483","devErrorMessage":"The request could not be completed due to data input errors.","userErrorMessage":"The request could not be completed due to data input errors.","userErrorKey":"error.validation.entity","validationErrors":[{"field":"files","error":"File doesn't have .wsdl, .xsd, .json, or .wadl extension","key":"File doesn't have .wsdl, .xsd, .json, or .wadl extension"}]}}}* Closing connection 0

* schannel: shutting down SSL/TLS connection with apim-ssg.<tenant_domain> port 9443

* schannel: clear security context handle

Environment

Release : 4.5

Component : API PORTAL

Resolution

Adjustments to the CURL - removed Origin 

C:\GMU>curl -k -X POST https://apim-ssg.<tenant_domain>:9443/tenant45/api-management/1.0/apis/f0484754-35c2-4b32-966a-723026c55b1e/assets -H "accept: application/json;charset=UTF-8" -H "authorization: Bearer xxxxxxxxxxxxxxx" -H "Content-Type:multipart/form-data" -F  "files=@/Users/<user>/Desktop/myapi12.json;type=application/json" -v

Note: Unnecessary use of -X or --request, POST is already inferred.

*   Trying 10.xx.xxx.xx...

* TCP_NODELAY set

* Connected to apim-ssg.<tenant_domain> (10.xx.xxx.xx) port 9443 (#0)

* schannel: SSL/TLS connection with apim-ssg.<tenant_domain> port 9443 (step 1/3)

* schannel: disabled server certificate revocation checks

* schannel: verifyhost setting prevents Schannel from comparing the supplied target name with the subject names in server certificates.

* schannel: sending initial handshake data: sending 184 bytes...

* schannel: sent initial handshake data: sent 184 bytes

* schannel: SSL/TLS connection with apim-ssg.<tenant_domain> port 9443 (step 2/3)

* schannel: failed to receive handshake, need more data

* schannel: SSL/TLS connection with apim-ssg.<tenant_domain> port 9443 (step 2/3)

* schannel: encrypted data got 1232

* schannel: encrypted data buffer: offset 1232 length 4096

* schannel: sending next handshake data: sending 1337 bytes...

* schannel: SSL/TLS connection with apim-ssg.<tenant_domain> port 9443 (step 2/3)

* schannel: encrypted data got 51

* schannel: encrypted data buffer: offset 51 length 4096

* schannel: SSL/TLS handshake complete

* schannel: SSL/TLS connection with apim-ssg.<tenant_domain> port 9443 (step 3/3)

* schannel: stored credential handle in session cache

> POST /tenant45/api-management/1.0/apis/f0484754-35c2-4b32-966a-723026c55b1e/assets HTTP/1.1

> Host: apim-ssg.<tenant_domain>:9443

> User-Agent: curl/7.55.1

> accept: application/json;charset=UTF-8

> authorization: Bearer xxxxxxxxxxxxxxxx

> Content-Length: 19386

> Expect: 100-continue

> Content-Type:multipart/form-data; boundary=------------------------b52a04ff5186acba

>

* schannel: client wants to read 102400 bytes

* schannel: encdata_buffer resized 103424

* schannel: encrypted data buffer: offset 0 length 103424

* schannel: encrypted data got 54

* schannel: encrypted data buffer: offset 54 length 103424

* schannel: decrypted data length: 25

* schannel: decrypted data added: 25

* schannel: decrypted data cached: offset 25 length 102400

* schannel: encrypted data buffer: offset 0 length 103424

* schannel: decrypted data buffer: offset 25 length 102400

* schannel: schannel_recv cleanup

* schannel: decrypted data returned 25

* schannel: decrypted data buffer: offset 0 length 102400

< HTTP/1.1 100 Continue

* schannel: client wants to read 102400 bytes

* schannel: encrypted data buffer: offset 0 length 103424

* schannel: encrypted data got 505

* schannel: encrypted data buffer: offset 505 length 103424

* schannel: decrypted data length: 476

* schannel: decrypted data added: 476

* schannel: decrypted data cached: offset 476 length 102400

* schannel: encrypted data buffer: offset 0 length 103424

* schannel: decrypted data buffer: offset 476 length 102400

* schannel: schannel_recv cleanup

* schannel: decrypted data returned 476

* schannel: decrypted data buffer: offset 0 length 102400

< HTTP/1.1 204 No Content

< Set-Cookie: PD-JSESSIONID=982607F87356BE3D97BCAEC1BBA3D322; Path=/tenant45/api-management/1.0/apis/f0484754-35c2-4b32-966a-723026c55b1e; Secure; HttpOnly; Domain=apim-ssg.<tenant_domain>

< X-Frame-Options: SAMEORIGIN

< Set-Cookie: gateaugage=; Max-Age=0; path=/; Secure; HttpOnly

< Set-Cookie: PD-JSESSIONID=; Max-Age=0; path=/; Secure; HttpOnly

< X-Application-Context: portal-data

< Date: Tue, 05 Jan 2021 15:14:41 GMT

< Server: CA-API-Gateway/9.0

<

* Connection #0 to host apim-ssg.<tenant_domain> left intact