Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
schulze1
Explorer

R81 API call for show-gateways-and-servers results in a generic error

Jump to solution

Hello,

 

we need to fetch the "gateways-and-servers" by an API call.

Actually the reply of the call is "generic error".

To test the API itself we used a different call "show-unused-objects", this returns the values correctly.

Any ideas why the cal results in a generic error?

 

Script:

#!/bin/bash


username="1234"

password="7896"

host="10.10.18.7/"

baseurl=https://$host/web_api


curl_cmd="curl --silent --insecure -X POST"


SID=`${curl_cmd} --insecure -H "Content-Type: application/json" -d @- $baseurl/login <<. | awk -F\" '/sid/ {print $4}'

{

"user":"$username" ,

"password":"$password" ,

"session-name":"TACO"

}

.`

printf "/n"
printf $SID


outnb=`curl --insecure -XPOST "https://10.10.18.7/web_api/show-gateways-and-servers" --data-binary "{\"details-level\": \"full\"}" -H "Content-Type: application/json" -H "X-chkp-sid: $SID" -O`
##Output generic error

outnb=`curl --insecure -XPOST "https://10.10.18.7/web_api/show-unused-objects" --data-binary "{\"details-level\": \"full\"}" -H "Content-Type: application/json" -H "X-chkp-sid: $SID" -O`
##output ok

${curl_cmd} -H "Content-Type: application/json" -H "X-chkp-sid: $SID" -d "{}" $baseurl/logout

 

Generated files:

[xxxx ~]$ more show-gateways-and-servers
{
"code" : "generic_error",
"message" : ""
}

[xxxx ~]$ more show-unused-objects
{
"objects" : [ {
"uid" : "726480c6-b5af-44a1-b471-74539cd8e66c",
"name" : "test network name",
"type" : "network",
"domain" : {
"uid" : "a0eebc99-afed-4ef8-bb6d-fedfedfedfed",
"name" : "System Data",
"domain-type" : "mds"
},
"broadcast" : "allow",
"subnet4" : "1.2.3.0",
"mask-length4" : 24,
"subnet-mask" : "255.255.255.0",
"nat-settings" : {
"auto-rule" : false
},
"comments" : "",
"color" : "black",
"icon" : "NetworkObjects/network",
"tags" : [ ],
"meta-info" : {
"lock" : "unlocked",
"validation-state" : "ok",
"last-modify-time" : {
"posix" : 1637075180517,
"iso-8601" : "2021-11-16T16:06+0100"
},
"last-modifier" : "avccdj",
"creation-time" : {
"posix" : 1637075180517,
"iso-8601" : "2021-11-16T16:06+0100"
},
"creator" : "avccdj"
},
"read-only" : true
} ],
"from" : 1,
"to" : 1,
"total" : 1
}

 

 

 

 

0 Kudos
1 Solution

Accepted Solutions
schulze1
Explorer
0 Kudos
2 Replies
Alex-
Advisor

I've tried your exact code on an R81 SMS, using curl_cli instead of curl and it worked for show-gateways-and-servers.

Running Take 65 if it makes any difference.

You might have a look at $FWDIR/api.elg and $FWDIR/api.csv where I could see such messages.

2022-05-11,10:34:43 +0200,"curl/7.61.1DEV","<removed>",login,PASSED,747
2022-05-11,10:34:44 +0200,"curl/7.61.1DEV","<removed>",show-gateways-and-servers,PASSED,1095
2022-05-11,10:34:48 +0200,"curl/7.61.1DEV","<removed>",show-unused-objects,PASSED,3687
2022-05-11,10:34:48 +0200,"curl/7.61.1DEV","<removed>",logout,PASSED,492

 

If something's wrong there you can try to restart the api service or depending of what happens create an SR.

0 Kudos
schulze1
Explorer
0 Kudos