API Connect

API Connect

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#API Connect
#Applicationintegration
#APIConnect
 View Only
  • 1.  Platform Rest api to publish a Product

    Posted Tue April 11, 2023 04:40 PM

    Hi Team,

    I am looking for some help around platform REST API's.
    I am trying to publish a product using below path of Platform-ProviderAPI:
    /api/spaces/{org}/{catalog}/{space}/publish
    I am passing product and api as a form data in Soap UI.
    No maater what I pass in the product I am seeing an error below:
    "The multipart 'product' must contain a single product definition"

    I am sending product json in an array as the form data in the request.

    Can you advise how can I resolve this.



    ------------------------------
    Sadhana
    ------------------------------


  • 2.  RE: Platform Rest api to publish a Product

    Posted Wed April 12, 2023 04:59 AM

    Hi,

    Please see my blog for some guidance: https://community.ibm.com/community/user/integration/blogs/nick-cawood/2023/02/23/api-connect-v10-provider-api-calls-api-lifecycle-c?CommunityKey=2106cca0-a9f9-45c6-9b28-01a28f4ce947

    I included one example of publishing direct from file to Catalog (bypassing drafts/Develop-section):

    • Publish a Product, from a file, direct to the Catalog bypassing creation in Drafts (run from the same directory as the files or use absolute paths as reference):

    curl -v -k -X POST $mgmt-url/api/catalogs/{org}/{catalog}/publish -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer $b' --header 'accept: application/json' --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' --form product='file=@"theProduct.yaml"' --form openapi='file=@"theAPI.yaml"'

    There are also examples of how to create APIs and Products into the drafts / Develop-section and then publish from there. Those examples might help you with the required syntax for APIs and Products:

    • Create a Draft API (using API yaml/json) in your API Manager Provider Organization:

    curl -v -k -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H "Authorization: bearer $b" $mgmt-url/api/orgs/{org}/drafts/draft-apis --data-raw '{"draft_api":{"swagger":"2.0","info":{"title":"theAPI","x-ibm-name":"theapi","version":"v1.0"},"schemes":["https"],"basePath":"/theapi","security":[{"clientID":[]}],"securityDefinitions":{"clientID":{"type":"apiKey","in":"header","name":"X-IBM-Client-Id"}},"x-ibm-configuration":{"phase":"realized","testable":true,"enforced":true,"properties":{"target-url":{"value":"https://randomuser.me/api","description":"The URL of the target service","encoded":false}},"catalogs":{},"cors":{"enabled":true},"application-authentication":{"certificate":false},"assembly":{"execute":[{"invoke":{"title":"invoke","version":"2.0.0","verb":"keep","target-url":"$(target-url)"}}]},"gateway":"datapower-api-gateway","type":"rest"},"paths":{"/getTestResults":{"get":{"responses":{"200":{"description":"Success!","schema":{"type":"object"}}},"consumes":[],"produces":[]}}}}}'

    • Create a Draft Product (using API yaml/json & containing the Draft API created above) in your API Manager Provider Organization:

    curl -v -k -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H "Authorization: bearer $b" $mgmt-url/api/orgs/{org}/drafts/draft-products --data-raw '{"draft_product":{"info":{"version":"1.0.0","title":"theProduct","name":"theproduct"},"gateways":["datapower-api-gateway"],"plans":{"default-plan":{"title":"Default Plan","description":"Default Plan","rate-limits":{"default":{"value":"100/1hour"}}}},"apis":{"theapiv1.0":{"name":"theapi:v1.0"}},"visibility":{"view":{"type":"public","orgs":[],"tags":[],"enabled":true},"subscribe":{"type":"authenticated","orgs":[],"tags":[],"enabled":true}},"product":"1.0.0"}}'



    ------------------------------
    Nick Cawood
    API Connect Consultant
    IBM Hybrid Cloud Integration Expert Labs
    IBM UK Ltd

    https://www.linkedin.com/in/nickcawood/
    ------------------------------



  • 3.  RE: Platform Rest api to publish a Product

    Posted Wed April 12, 2023 05:02 AM

    My three blogs on the subject:

    https://community.ibm.com/community/user/integration/blogs/nick-cawood/2023/02/22/some-advice-about-using-the-api-connect-v10-apic-t?CommunityKey=2106cca0-a9f9-45c6-9b28-01a28f4ce947

    https://community.ibm.com/community/user/integration/blogs/nick-cawood/2023/02/23/api-connect-v10-provider-api-calls-api-lifecycle-c?CommunityKey=2106cca0-a9f9-45c6-9b28-01a28f4ce947

    https://community.ibm.com/community/user/integration/blogs/nick-cawood/2023/02/23/api-connect-v10-rest-api-calls-consumer-api-genera?CommunityKey=2106cca0-a9f9-45c6-9b28-01a28f4ce947



    ------------------------------
    Nick Cawood
    API Connect Consultant
    IBM Hybrid Cloud Integration Expert Labs
    IBM UK Ltd

    https://www.linkedin.com/in/nickcawood/
    ------------------------------



  • 4.  RE: Platform Rest api to publish a Product

    Posted Wed April 12, 2023 04:14 PM

    Thank you Nick,

    Do you have anything to create and update Drafts.
    I see api's to create a draft and one to update the draft.
    Do you have any api that can do both.

    Below helped

    • Publish a Product, from a file, direct to the Catalog bypassing creation in Drafts with APIs which include WSDLs:

    curl -v -k -X POST $mgmt-url/api/catalogs/{org}/{catalog}/publish -H 'Accept: application/json' -H "Content-Type: multipart/form-data" -H "Authorization: Bearer $b" -F "product=@/directory/file/location/fromwsdlProduct_1.0.0.yaml;type=application/yaml" -F "openapi=@/directory/file/location/fromwsdlAPI_1.0.0.yaml;type=application/yaml" -F "wsdl=@/directory/file/location/Client-backend-system-WSDL.wsdl;type=application/wsdl"  



    ------------------------------
    Sadhana Guduru
    ------------------------------



  • 5.  RE: Platform Rest api to publish a Product

    Posted Thu April 13, 2023 04:22 AM

    Hi,

    I'm glad you found something useful from my blogs.

    I'm afraid I don't understand your request. What use-case requires a draft to be created and updated in the same API call?

    Maybe you can provide more details to explain what you are hoping to achieve.



    ------------------------------
    Nick Cawood
    API Connect Consultant
    IBM Hybrid Cloud Integration Expert Labs
    IBM UK Ltd

    https://www.linkedin.com/in/nickcawood/
    ------------------------------



  • 6.  RE: Platform Rest api to publish a Product

    Posted Mon April 17, 2023 09:33 AM

    No Problem Nick,I was looking for a command which can both create and update api and product drafts.
    But that is fine I have put a script to do both.
    Thank you for the support!



    ------------------------------
    Sadhana Guduru
    ------------------------------