heba_rachid
heba_rachid

Reputation: 1

Publishing a RAML file to Exchange via Exchange REST Api error

I have been following MuleSoft's tutorial regarding publishing an asset to exchange: https://docs.mulesoft.com/exchange/exchange-api,

this is the command used: (under publish an asset module)

When I execute this command using cmd, I receive the following error but I'm not able to pinpoint what's the error.

The command:

curl -v -H 'Authorization: bearer b90ed1ce-671c-4726-9d25-4aacd7cb8bb4'
-H 'x-sync-publication: true'
-F 'name=RAML asset name' 
-F 'description=Description of the asset' 
-F 'keywords=this, is, the, best, raml'
-F 'dependencies=68ef9520-24e9-4cf2-b2f5-620025690913:training-american-flight-data-type:1.0.1,68ef9520-24e9-4cf2-b2f5-620025690913:training-american-flights-example:1.0.1'
-F 'properties.mainFile=american-flights-api.raml'
-F 'properties.apiVersion=v1' 
-F 'files.raml.zip=training-american-flights-api-1.0.0-raml.zip' https://anypoint.mulesoft.com/exchange/api/v2/organizations/:org id/assets/:org id/doc-api-v2/1.0.0

The error:

* Could not resolve host: bearer
* Closing connection 0
curl: (6) Could not resolve host: bearer
* Could not resolve host: b90ed1ce-671c-4726-9d25-4aacd7cb8bb4'
* Closing connection 1
curl: (6) Could not resolve host: b90ed1ce-671c-4726-9d25-4aacd7cb8bb4'
* Could not resolve host: true'
* Closing connection 2
curl: (6) Could not resolve host: true'
* Could not resolve host: asset
* Closing connection 3
curl: (6) Could not resolve host: asset
* Could not resolve host: name'
* Closing connection 4
curl: (6) Could not resolve host: name'
* Could not resolve host: of
* Closing connection 5
curl: (6) Could not resolve host: of
* Could not resolve host: the
* Closing connection 6
curl: (6) Could not resolve host: the
* Could not resolve host: asset'
* Closing connection 7
curl: (6) Could not resolve host: asset'
* Could not resolve host: is,
* Closing connection 8
curl: (6) Could not resolve host: is,
* Could not resolve host: the,
* Closing connection 9
curl: (6) Could not resolve host: the,
* Could not resolve host: best,
* Closing connection 10
curl: (6) Could not resolve host: best,
* Could not resolve host: raml'
* Closing connection 11
curl: (6) Could not resolve host: raml'
*   Trying 52.87.53.99:443...
* Connected to anypoint.mulesoft.com (52.87.53.99) port 443 (#12)
* schannel: disabled automatic use of client certificate
* schannel: ALPN, offering http/1.1
* ALPN, server did not agree to a protocol
> POST /exchange/api/v2/organizations/d44a45b6-2599-4559-9a4e-f4fef4c5500b/assets/d44a45b6-2599-4559-9a4e-f4fef4c5500b/doc-api-v2/1.0.0 HTTP/1.1
> Host: anypoint.mulesoft.com
> User-Agent: curl/7.79.1
> Accept: */*
> Content-Length: 1031
> Content-Type: multipart/form-data; boundary=------------------------daa7e3a71c8392fb
>
* We are completely uploaded and fine
* Mark bundle as not supporting multiuse
< HTTP/1.1 400 Bad Request
< access-control-allow-origin: *
< cache-control: no-store, no-cache, must-revalidate, proxy-revalidate
< content-security-policy: default-src 'self';base-uri 'self';block-all-mixed-content;font-src 'self' https: data:;form-action 'self';frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests
< Content-Type: application/json; charset=utf-8
< cross-origin-embedder-policy: require-corp
< cross-origin-opener-policy: same-origin
< cross-origin-resource-policy: same-origin
< Date: Wed, 22 Jun 2022 06:11:50 GMT
< etag: W/"e0-0kCi5++SWwjWlVDLUPqO3gvy8eU"
< expect-ct: max-age=0
< expires: 0
< origin-agent-cluster: ?1
< pragma: no-cache
< referrer-policy: no-referrer
< Server: nginx
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< surrogate-control: no-store
< x-content-type-options: nosniff
< x-dns-prefetch-control: off
< x-download-options: noopen
< x-envoy-decorator-operation: xapi-service.exchange.svc.cluster.local:80/*
< x-envoy-upstream-service-time: 12
< x-frame-options: SAMEORIGIN
< x-permitted-cross-domain-policies: none
< x-request-id: 941df740-8566-43d5-b647-07599048492f
< x-xss-protection: 0
< Content-Length: 224
< Connection: keep-alive
<
{"name":"BadRequestError","status":400,"message":"Request failed to validate against RAML definition","details":[{"type":"header","dataPath":"authorization","keyword":"required","message":"invalid header (required, true)"}]}* Connection #12 to host anypoint.mulesoft.com left intact

As a RAML file I used the same one in the documentation as a sample. It is available in this documentation under RAML section:

https://anypoint.mulesoft.com/exchange/portals/anypoint-platform/f1e97bc6-315a-4490-82a7-23abe036327a.anypoint-platform/exchange-experience-api/minor/2.0/pages/Asset%20Creation/

The organization id and the group id are the same, the asset id hold the name of the uploaded doc and the version is 1.0.0 and I added an access token so the API resulted in: https://anypoint.mulesoft.com/exchange/api/v2/organizations/:org id/assets/:group id/doc-api-v2/1.0.0

Upvotes: 0

Views: 1080

Answers (1)

aled
aled

Reputation: 25709

The error indicates the the request is missing the Authorization header and the screenshot of the execution confirms it. It seems that the execution doesn't match the curl command shared.

Note that it would have been easier to find if you share the complete command and execution output as one block of text.

Upvotes: 0

Related Questions