Using curl to access a Mulesoft API mock requires a little trick. Mulesoft gives you the ability to test out a mock of your API design. The easiest way to try the API is to click on the Documentation button on the right side of the API Designer, select an endpoint, and click “Try it.” If you have made the mock public, you can also use curl to test, but there is a little trick to using curl.
- First, go to Mocking Service Configuration in the API Designer, and enable “Make Public.”
- Copy the base URL (domain name and first part of the path)
- Go back to the Documentation to get the next part of the URL. There is a cURL code example here, but the path in this example is wrong. Instead, look for the part of the path that looks like /master/m/products/{productId}.
- Ignore the /master/m/ part
- Append the rest of the path to the base URL you copied above
- Add basic authentication with -h username:password
- Test in curl. Be sure to replace any values in braces {} with actual values
curl -X GET https://anypoint.mulesoft.com/mocking/api/v1/links/{some-long-uuid-type-number}/products/2 -u mulesoft:mulesoft