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.

 View Only
Expand all | Collapse all

Moving using APIC CLI to REST API

  • 1.  Moving using APIC CLI to REST API

    Posted Sun February 09, 2025 08:25 AM

    Hello,

    We have been using APIC CLI to configuration applications and planning to move to using REST APIs. We are using on-prem APIC v10.0.5.7, can you point me to documentation for the below commands. I tried using --debug option as per this blog , but did not get the REST API output.

    apic create:api --title "tst-api" --name tst-api --version 2.0.0 --basepath /test --target-url <xxxx>--template tst-api.hbs --product "tst-product"
    apic validate tst-product.yaml
    apic products:publish --scope space tst-product.yaml --server <xxxx> --org <xxxx> --catalog <xxxx> --space <xxxx>
    apic apis:get tst-api:2.0.0 --server <xxxx> --org <xxxx> --catalog <xxxx> --scope <xxxx> --space <xxxx>
    apic draft-products:create tst-product.yaml --server <xxxx> --org <xxxx>
    apic draft-products:update tst-product:2.0.0 tst-product.yaml --server <xxxx> --org <xxxx>
    apic subscriptions:create --server <xxxx> --org <xxxx>--catalog <xxxx> --space <xxxx> --consumer-org <xxxx> --app <xxxx> subscription.json
    apic logout --server <xxxx>

    Thanks
    Raj



    ------------------------------
    Dhanraj Uchil
    ------------------------------


  • 2.  RE: Moving using APIC CLI to REST API

    Posted Mon February 10, 2025 12:54 AM
    Edited by Nick Cawood Mon February 10, 2025 09:09 AM

    Comment deleted.

    Posted in error.  Please ignore.

    ------------------------------
    Nick Cawood
    API Connect Consultant
    IBM Expert Labs
    IBM UK Ltd

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



  • 3.  RE: Moving using APIC CLI to REST API

    Posted Tue February 11, 2025 07:10 PM

    Hi,

    --debug works most of the time for us.

    can you show the logs from e.g. the command?

    apic products:publish --scope space tst-product.yaml --server <xxxx> --org <xxxx> --catalog <xxxx> --space <xxxx> --debug



    ------------------------------
    Jeroen Willems
    Integration Architect - Managing Partner
    Integration Designers
    ------------------------------



  • 4.  RE: Moving using APIC CLI to REST API

    Posted Mon February 24, 2025 06:00 PM

    Hi Jeroen,

    I have tired the --debug with all commands, the command works fine with no error, but there is not output. 

    apic create:api --title "tst-api" --name tst-api --version 2.0.0 --basepath /test --target-url <xxxx>--template tst-api.hbs --product "tst-product"
    apic validate tst-product.yaml --debug


    Also, use `--format json` or `--format yaml` on all CLI commands as you will get far more content back, both when commands are successful and when errors occur. 

    apic create:api --title "tst-api" --name tst-api --version 2.0.0 --basepath /test --target-url https://tst.bcbsnc.com --template tst-api.hbs --product "tst-product" --format json --debug

    Error: unknown flag: --format

    I am running these commands in Amazon Linux docker container.

    Thanks
    Raj



    ------------------------------
    Dhanraj Uchil
    ------------------------------



  • 5.  RE: Moving using APIC CLI to REST API

    Posted Mon February 24, 2025 06:27 PM

    afaik apic create:api & apic validate are commands that run locally in the toolkit (cli), so no rest api's are called here.

    can you provide the output for

    apic products:publish --scope space tst-product.yaml --server <xxxx> --org <xxxx> --catalog <xxxx> --space <xxxx> --debug 



    ------------------------------
    Jeroen Willems
    Integration Architect - Managing Partner
    Integration Designers
    ------------------------------



  • 6.  RE: Moving using APIC CLI to REST API

    Posted Mon February 24, 2025 07:19 PM
    $ apic create:api --title "tst-api" --name tst-api --version 2.0.0 --basepath /test --target-url https://tst.nc.com --template tst-api.hbs --product "tst-product" --debug
    Created tst-api.yaml API definition [tst-api:2.0.0]
    Created tst-product.yaml product definition [tst-product:1.0.0]
    
    $ apic validate tst-product.yaml --debug
    Validated tst-product.yaml product definition [tst-product:1.0.0]
    Validated tst-api.yaml API definition [tst-api:2.0.0]
    
    
    Without --debug flag
    $ apic create:api --title "tst-api" --name tst-api --version 2.0.0 --basepath /test --target-url https://tst.nc.com --template tst-api.hbs --product "tst-product" 
    Created tst-api.yaml API definition [tst-api:2.0.0]
    Created tst-product.yaml product definition [tst-product:1.0.0]
    
    $ apic validate tst-product.yaml
    Validated tst-product.yaml product definition [tst-product:1.0.0]
    Validated tst-api.yaml API definition [tst-api:2.0.0]
    
    
    With --format and --debug flag
    $ apic create:api --title "tst-api" --name tst-api --version 2.0.0 --basepath /test --target-url https://tst.nc.com --template tst-api.hbs --product "tst-product" --format json --debug
    
    Error: unknown flag: --format


    ------------------------------
    Dhanraj Uchil
    ------------------------------



  • 7.  RE: Moving using APIC CLI to REST API

    Posted Tue February 25, 2025 04:54 AM

    The commands listed above do not have any output, just responses.
    For example if you try to list or get something this will have an output which you can format with the --format options and will show debug information with the --debug parameter.

    Try these commands to see the differences:

    ./apic products:list-all --catalog <CATALOG> --org <PORG> --server <SERVER> --scope catalog

    ./apic products:list-all --catalog <CATALOG> --org <PORG> --server <SERVER> --scope catalog --debug

    ./apic products:list-all --catalog <CATALOG> --org <PORG> --server <SERVER> --scope catalog --debug --format json

    ./apic products:list-all --catalog <CATALOG> --org <PORG> --server <SERVER> --scope catalog --debug --format yaml

    The --debug parameter will show the equivalent cURL command being used by the Toolkit including the Bearer Token and API call & headers used.



    ------------------------------
    Nick Cawood
    API Connect Consultant
    IBM Expert Labs
    IBM UK Ltd

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



  • 8.  RE: Moving using APIC CLI to REST API

    Posted Tue February 25, 2025 04:52 PM

    Thanks Nick, that helped. 

    Would you be able let me know if there is a REST API call for 

    $ apic create:api --title "tst-api" --name tst-api --version 2.0.0 --basepath /test --target-url https://tst.nc.com --template tst-api.hbs --product "tst-product"
    
    $ apic validate test-product.yaml


    ------------------------------
    Dhanraj Uchil
    ------------------------------



  • 9.  RE: Moving using APIC CLI to REST API

    Posted Tue February 25, 2025 05:15 PM

    To validate a draft API: https://apic-api.apiconnect.ibmcloud.com/v10/#/IBMAPIConnectPlatformProviderAPI_200/operation/%2Forgs%2F{org}%2Fdrafts%2Fdraft-apis%2F{draft-api-name}%2F{draft-api-version}%2Fvalidate/post

    As far as I know there is not equivalent to build an API from a template in the Provider-API but you can create from code or from file using the Provider-API, see my blog for different options: https://community.ibm.com/community/user/integration/blogs/nick-cawood/2023/02/23/api-connect-v10-provider-api-calls-api-lifecycle-c 



    ------------------------------
    Nick Cawood
    API Connect Consultant
    IBM Expert Labs
    IBM UK Ltd

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



  • 10.  RE: Moving using APIC CLI to REST API

    Posted Tue February 25, 2025 05:28 PM

    Thanks Jeroen. Thanks Nick. Appreciate all the help.



    ------------------------------
    Dhanraj Uchil
    ------------------------------