Active IQ Unified Manager Discussions

Using Postman with NetApp API Services.

olson
6,763 Views

Postman is a REST development and command testing tool to allow developers and administrators build new commands for administration and provisioning. To utilized the drag and drop capabilities / double click capabilities to quickly build out new REST commands the Swagger template from the API Server can to be installed as a collection. 

 

 

Here are the steps required to import the Swagger JSON as a template into Postman collection. 

 

  1. Install Postman

        Postman per platform can be found at https://www.getpostman.com/

 

 2.  Install API Services

 

       API Services can be found on the netapp support site

      This document assume the use of default ports if you are not using default ports you will need ot ajust things as required.

 

 3.  On the API Server go to this address

 

      https://{Servers NAME or IP}:8443/swagger.json

 

      You will want to select all data in the body and save it to a local text file.

 

4.  Modify the Second line of the file Add the following on the second line

<tab>”host”: “Server Name or IP :8443”

 

Save Document as NetApp_API.json

 

Launch postman

In the upper left corner of postman Click import.

 

Drag and drop file to the import screen.

 

On the 3 dots next to the OnCommand API Services … click the edit command.

 

Click Authorization

Select Basic Authentication.

Update the Username and the password for your API Services server.

 

You can now browse and use commands with API services.

 

 

3 REPLIES 3

asulliva
6,733 Views

Thanks John, this is great!

 

One thing to note, I had to use the URL "https://<API-S Server name or IP>:8443/api/1.0/api-docs/ontap" to get the Swagger docs (I'm using API-S 1.2 RC1, FYI).

 

Also, you can do the same thing for NSLM too (I'm using 1.0 RC3):

 

  • SLO APIs - https://<NSLM server name or IP>:8443/api/api-docs/slo
  • ONTAP APIs - https://<NSLM server name or IP>:8443/api/api-docs/ontap2.0

 

Thanks again!

 

Andrew

If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

acjackson
5,998 Views

I'm using API Services 2.1 and trying to import the swagger.json file. But I'm getting the following error:

 

 

Error while importing: format not recognized

 

My swagger.json file looks like this:

{
"host": "https://API_SERVICS_IP:8443/api/1.0/api-docs/ontap",
"basePath": "/api",
"schemes": [
"https"
],
"swagger": "2.0",
"info": {
"title": "OnCommand API Services",
"version": "1.0"
},
"tags": [
{

... 

If I try to import the unmodified swagger.json or with ”host”: “API_SERVICES_API:8443”, I still get the same error.

 

What am I doing wrong?

EricBecker
5,929 Views

I encountered the same error with postman 6.0.10 and api services 2.1.0.

 

Error while importing: format not recognized

 

When I loaded the swagger json file in visual studio code, the python linter identified duplicate "QtreeOntap1.0" keys at lines 184934 and 185019.  I pulled the first (lines 184934 through 185018) just so I could get it working. Swagger json import file looks like:

 

{
  "host": "API_SERVICES_IP:8443",
  "basePath": "/api",
  "schemes": [
    "https"
  ],
  "swagger": "2.0",
  "info": {
    "title": "OnCommand API Services",
    "version": "1.0"
  },

 

Everything seems to work.  It looks like postman tries to load every single parameter in the URL by default.  For example, 5.0 -> Retreive all the aggregates looks like

 

https://API_SERVICES_IP:8443/api/5.0/ontap/aggregates?snapshot_size_total={{snapshot_size_total}}&snaplock_type={{snaplock_type}}&aggregate_type={{aggregate_type}}&state={{state}}&raid_size={{raid_size}}&node_key={{node_key}}&is_composite={{is_composite}}&size_avail_percent={{size_avail_percent}}&snapshot_size_used={{snapshot_size_used}}&object_store_key={{object_store_key}}&volume_compression_space_savings={{volume_compression_space_savings}}&name={{name}}&size_used_percent={{size_used_percent}}&size_total={{size_total}}&is_snaplock={{is_snaplock}}&mirror_status={{mirror_status}}&key={{key}}&is_hybrid_enabled={{is_hybrid_enabled}}&size_avail={{size_avail}}&cluster_key={{cluster_key}}&uses_shared_disks={{uses_shared_disks}}&hybrid_cache_size_total={{hybrid_cache_size_total}}&raid_status={{raid_status}}&volume_dedupe_space_savings={{volume_dedupe_space_savings}}&total_committed={{total_committed}}&block_type={{block_type}}&size_used={{size_used}}&raid_type={{raid_type}}&is_hybrid={{is_hybrid}}&has_local_root={{has_local_root}}&snapshot_size_avail={{snapshot_size_avail}}&has_partner_root={{has_partner_root}}&total_reserved_space={{total_reserved_space}}&sortBy={{sortBy}}&maxRecords={{maxRecords}}&nextTag={{nextTag}}&atomLinks={{atomLinks}}

 

If you don't set the ~30 {{variables}} the request bombs because can't resolve them and api services rejects the request. 

 

{
    "status": {
        "code": "FAILED",
        "error": {
            "errno": 1104,
            "message": "The requested URL is not found in the server.",
            "reason": "RESTEASY003870: Unable to extract parameter from http request: javax.ws.rs.QueryParam(\"maxRecords\") value is {1} for public javax.ws.rs.core.Response com.netapp.apiserver.ontap.resources5.AggregateResource.getAllAggregates(javax.ws.rs.core.UriInfo,javax.ws.rs.core.HttpHeaders,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.Boolean,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.Boolean,java.lang.String,java.lang.String,java.lang.Boolean,java.lang.String,java.lang.String,java.lang.Boolean,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.Boolean,java.lang.Boolean,java.lang.String,java.lang.Boolean,java.lang.String,java.lang.String,long,java.lang.String,boolean) throws com.netapp.apiserver.exception.ApiServicesException"
        }
    }
}

 

For now I just delete everything after the "?" in the URL; it's easier than clicking params and deselecting each param by hand and I don't see a way to deselect them all by default in the collection, environment, or global postman preferences.

 

Public