Management Software

Reply
New Contributor
Posts: 4
Registered: ‎10-26-2017

Rest API - Error with POST command

I'm trying to run a few zoning steps and the http 500 error doesn't specify what exactly the exception error code. Looking for assistance, thank you for reading.

('Status=', 500)
{'_content': '<html><head><title>Error</title></head><body>Internal Server Error</body></html>',
'_content_consumed': True,
'connection': <requests.adapters.HTTPAdapter object at 0x0000000002A2F400>,
'cookies': <RequestsCookieJar[]>,
'elapsed': datetime.timedelta(0, 0, 435000),
'encoding': 'UTF-8',
'headers': {'Date': 'Thu, 26 Oct 2017 22:09:38 GMT', 'Connection': 'keep-alive', 'Content-Type': 'text/html;charset=UTF-8', 'Content-Length':
'history': [],
'raw': <requests.packages.urllib3.response.HTTPResponse object at 0x0000000002A2FC18>,
'reason': 'Internal Server Error',
'request': <PreparedRequest [POST]>,
'status_code': 500,
'url': u'https://10.188.131.20/rest/resourcegroups/All/fcfabrics/10:00:50:EB:1A:A9:29:80/createzoningobject'}

Brocade Moderator
Posts: 414
Registered: ‎03-29-2011

Re: Rest API - Error with POST command

Hi,

 

from the documentation, it look like your query parameters are invalid:

 

If the URI is correct, the server checks the query parameter values for correctness. If the query parameters are invalid, the REST

operation fails with HTTP status code of 500 (Internal Server Error) and an RSException. The value of the error code depends

on the exact error.

 

Are you able to share your POST data which you use? 




If this provided you with a solution to this issue, please mark it with the button at the bottom "Accept as solution".


Any and all information provided by me is not reviewed, approved or endorsed by Brocade and is provided solely as a convenience for Brocade customers. All systems and all networks are different and unique. If you have a service affecting network problem, please open a TAC service request for service through Brocade, or through your OEM equipment provider. If this provided you with a solution to this issue, please mark it with the button at the bottom "Accept as solution"
New Contributor
Posts: 4
Registered: ‎10-26-2017

Re: Rest API - Error with POST command

[ Edited ]

I was able to get the fabric keys by entering username/password before this step, there is no RSexception error which is why I'm not able to debug where the problem is.

 

These are my next steps and it fails at the payload section.

 

start_zoning(token, session, fabric_key)
payload = make_zoning_payload()
create_zoning_objects(token, payload, fabric_key)

 

def create_zoning_objects(WStoken, payload, fabric_key):
print("Creating Aliases and Zones...")
url = base_url + 'resourcegroups/All/fcfabrics/{}/createzoningobject'
data=payload
headers={
"WStoken": WStoken,
"Accept": "application/vnd.brocade.networkadvisor+json;version=v1",
"Content-type": "application/vnd.brocade.networkadvisor+json;version=v1"
}
if confirm("Create the following zoning object:", data):
r = requests.post(url.format(fabric_key), data=json.dumps(data), headers=headers, verify=False)
print("Status=", r.status_code)
if r.status_code != 200:
# print("Message=" + str(r.RSException))
pprint(r.__dict__)
return True
else:
return False

def make_zoning_payload():
payload = {"zones": [], "zoneAliases": []}
while again("Do you want to create an alias?"):
name = raw_input('Alias name: ')
wwn = raw_input('Enter all wwns seperated by commas: ')
payload['zoneAliases'].append({"name":name, "memberNames":wwn.split(',')})
while again("Do you want to create a zone? "):
name = raw_input("Zone name: ")
aliases = raw_input("Enter all aliases for this zone seperated by commas:")
payload['zones'].append({"name": name, "aliasNames": aliases.split(',')})
return payload

 

Complete Output is below, there doesn't seem to be any RSexception error.

 

Do you want to create an alias?y
Alias name: test1
Enter all wwns seperated by commas: 11:22:33:44:55:66:77:88
Do you want to create an alias?y
Alias name: test2
Enter all wwns seperated by commas: 88:77:66:55:44:33:22:11
Do you want to create an alias?n
Do you want to create a zone? y
Zone name: test1_test2
Enter all aliases for this zone seperated by commas:test1,test2
Do you want to create a zone? n
Creating Aliases and Zones...
Create the following zoning object:
{'zoneAliases': [{'memberNames': ['11:22:33:44:55:66:77:88'],
'name': 'test1'},
{'memberNames': ['88:77:66:55:44:33:22:11'],
'name': 'test2'}],
'zones': [{'aliasNames': ['test1', 'test2'], 'name': 'test1_test2'}]}
Does this look right? :y
('Status=', 500)
{'_content': '<html><head><title>Error</title></head><body>Internal Server Error</body></html>',
'_content_consumed': True,
'connection': <requests.adapters.HTTPAdapter object at 0x0000000002A2F400>,
'cookies': <RequestsCookieJar[]>,
'elapsed': datetime.timedelta(0, 0, 435000),
'encoding': 'UTF-8',
'headers': {'Date': 'Thu, 26 Oct 2017 22:09:38 GMT', 'Connection': 'keep-alive', 'Content-Type': 'text/html;charset=UTF-8', 'Content-Length':
'history': [],
'raw': <requests.packages.urllib3.response.HTTPResponse object at 0x0000000002A2FC18>,
'reason': 'Internal Server Error',
'request': <PreparedRequest [POST]>,
'status_code': 500,
'url': u'https://IP/rest/resourcegroups/All/fcfabrics/10:00:50:EB:1A:A9:29:80/createzoningobject'}

 

New Contributor
Posts: 4
Registered: ‎10-26-2017

Re: Rest API - Error with POST command

I responded with my function and it seemed to have gotten deleted. Did you receive my response?

Brocade Moderator
Posts: 414
Registered: ‎03-29-2011

Re: Rest API - Error with POST command

Hi,

 

yes. I did. I think you forgotten the zoning type - from REST API manual

 

2017-10-27-zone-rest.PNG

And alsoA

And also, did you start controlzonetransaction before - an transaction is needed around....  i hav attached 14.2.1 rest api guide




If this provided you with a solution to this issue, please mark it with the button at the bottom "Accept as solution".


Any and all information provided by me is not reviewed, approved or endorsed by Brocade and is provided solely as a convenience for Brocade customers. All systems and all networks are different and unique. If you have a service affecting network problem, please open a TAC service request for service through Brocade, or through your OEM equipment provider. If this provided you with a solution to this issue, please mark it with the button at the bottom "Accept as solution"
New Contributor
Posts: 4
Registered: ‎10-26-2017

Re: Rest API - Error with POST command

[ Edited ]

Thank you for the response. 
Yes, Step 1 which is startcontrolzoning trasaction seems to work.

 

Adding type into Step 2 didn't work.

 

Actually tried testing step 2 from the guide as shown still got the error, if it shows the RSException code it would help. Would there be any other logs we can look at?

 

('Status=', 500)
{'_content': '<html><head><title>Error</title></head><body>Internal Server Error</body></html>',
'_content_consumed': True,
'connection': <requests.adapters.HTTPAdapter object at 0x000000000299FE80>,
'cookies': <RequestsCookieJar[]>,
'elapsed': datetime.timedelta(0, 0, 440000),
'encoding': 'UTF-8',
'headers': {'Date': 'Fri, 27 Oct 2017 18:31:11 GMT', 'Connection': 'keep-alive', 'Content-Type': 'text/html;charset=UTF-8', 'Content-Length'
'history': [],
'raw': <requests.packages.urllib3.response.HTTPResponse object at 0x000000000299F860>,
'reason': 'Internal Server Error',
'request': <PreparedRequest [POST]>,
'status_code': 500,
'url': u'https://IP/rest/resourcegroups/All/fcfabrics/10:00:50:EB:1A:A9:29:80/createzoningobject'}

Join the Community

Get quick and easy access to valuable resource designed to help you manage your Brocade Network.

vADC is now Pulse Secure
Download FREE NVMe eBook