cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

22717
Views
30
Helpful
32
Replies
hamoudud1
Beginner

Multi Network Object POST

Dear Support,

am trying to use API to push a bulk of configuration to Firepower 6.1 or 6.2 but without success, i tried to POST multi Network Object as shown below :

under network i POST the below configuration:

 

https://xxx.xxx.xxx.xxx/api/fmc_config/v1/domain/e233abec-e0f2-11e3-2321-6d9ed49b625f/object/networks

  Body:

-----------------------

{
"name":"testing",
"type":"Network",
"description": "testing",
"value": "2.2.90.0/24"
},

{
"name":"testing2",
"type":"Network",
"description": "testing2",
"value": "2.2.91.0/24"
}

----------------

it return with Syntax errors.

can you please provide me with right way to POST multi network Object or any kind of configuration through REST API.

BR,

Hamoud Hamdan 

32 REPLIES 32

Hello.

 

I have the next issue, when I run the next commands:

python prueba.py Prueba.csv

 

File "prueba.py", line 59
reader = csv.DictReader(open(variables_file, 'rb'))
^
IndentationError: expected an indented block

 

***************************************************************

This is the code of python in the file, the file "prueba.csv" contains the next:

 

prueba.CSV

name type value description
test Network 6.6.6.0/24 test

 

Hello mohan88481,

How should the CSV file be?

Best Regards,

Can someone tell me why having the data in a file called items that looks like this doesn't work? I keep getting 422 errors:
[items.txt]
{ "name": "test6", "value": "1.1.1.1/24", "type": "Network" }
Looks like you are missing description item

Nope, originally I thought it was the 1.1.1.1/24 so I fixed it to be 1.1.1.0/24 but still will not use it.

Is not your request data should look like this?

{ "name": "Test6", "type": "Network", "value": "1.1.1.0/24", "description": "Test Description" }

instead of

{ "name": "test6", "value": "1.1.1.1/24", "type": "Network" }

/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py:794: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
InsecureRequestWarning)
{ "name": "Test6", "type": "Network", "value": "1.1.1.0/24", "description": "Test Description" }

Status code is: 422

Nope still doesn't like it. I get this every time.

[moved]

 

Dear Neipatel,

 

I would like to reopen this case because I have to put over 1500 objects (url, network, host,range) into an FMC (v 6.2.2).

 

The goal is to migrate from an ASA cluster to a Firepower 9300 cluster. And for that, I use the API for extract the data from the ASA, formats it for the Firepower and use the Firepower API for inject the formatted objects

 

My problem is:

- All the examples that I found on the Cisco site show how to post a single object

- The limitation of 120 requests by minutes break my loop

- I'm unable to find a correct and a exact syntax of the JSON body that I need to insert into my API request for post some objects.

 

First of all I would like to know if it's definitely possible to insert some objects in the same API request.

If it's possible, can someone give me the simplest possible example in python language or the syntax in JSON that I have to insert in my python code. 

 

Tanks for all.

 

 

 

Hello,
Any news in this case? Is it possible to creat multiple objects with FMC 6.2 API?

Regards and thanks for all

Still no bulk import of network objects in the FMC as of 6.2.2.2. Have you tried using the migration tool to import?
Hkuespert
Beginner

Hey Guys -- to piggy back on this, I got bulk imports working with Postman.

 

Create your basic POST with proper header (X-auth-access-token) and authorization.

 

Set path to: https://<firesight manager ip>/api/fmc_config/v1/domain/<domain UUID>/object/networks  (can change this to hosts if you're importing hosts)

 

Next modify your body -- set to raw -- type JSON (on the end) -- and use the following:

 

{"type": "{{type}}","value": "{{value}}","description": "{{description}}","name": "{{name}}"}

 

Save it.

 

Next Go to Runner  (top)

 

Select your POST in your collection (left side)

 

Next select your data file (left bottom, browse).

 

Format should be like so:

[
{
"type": "Network",
"value": "5.5.5.5/21",
"description": "My Route",
"name": "RT-5.5.5.5-21"
},
{
"type": "Network",
"value": "6.6.6.6/24",
"description": "My Route",
"name": "RT-6.6.6.6-24"
}]

 

Change type to JSON, click preview, should see data as you would expect.

 

Click Run <collection name> at bottom (blue button)

 

You should receive results back that state "201 Created ....."

 

 

 

 

 

How many iterations is Postman using? If it's more than one, then it's not really doing a "bulk" creation of the network objects. It's using multiple calls to the api, creating only one object per api call.

This is similar to an earlier suggestion where someone said to use a for loop to iterate through a list of network objects to create one object at a time until all the objects in the list were created.

You are correct, they are multiple calls.  I was trying to offer an additional way to overcome the lack of the bulk import feature.  Sorry for any misleading!

Thanks so much for this info!  Though only the first entry in the JSON file containing the hosts is being created?

 

Below is the contents of test_host.json which I'm selecting in the Collection Runner in Postman.  The preview shows both lines of data.  And the Run Results show 201 Created.  But only the first object is created.  

 

Any advice or thoughts?

 

[
{
"type": "Host",
"value": "7.7.7.7",
"description": "TEST-HOST-7-Desc",
"name": "TEST-HOST-7"
},
{
"type": "Host",
"value": "8.8.8.8",
"description": "TEST-HOST-8-Desc",
"name": "TEST-HOST-8"
}]

Tryed your method with Postmon but I keep receiving 401 error Unauthorized, even though I've generated the toke correctly. Any tips?