I have this data and when I run the script i get the error as " "guid": "Internal" TypeError: unhashable type: 'list'"
Here is my code, the other dictionaries in the data work fine, but only the last one has problems. Can someone tell me the correct syntax please.
import requests
headers = {
'Authorization': 'FortifyToken MmRjODVjZjctOWE2Zi00NGQxLWFkZTAtZmE2ZjUxZmZiYmU1',
'Content-Type': 'application/json',
'Accept': 'application/json'
}
json_data = {
[
{
"guid": "DevPhase",
"attributeDefinitionId": "5578",
"values": [
{
"guid": "Active"
}
]
},
{
"guid": "Accessibility",
"attributeDefinitionId": "5590",
"values": [
{
"guid": "externalpublicnetwork"
}
]
},
{
"guid": "DevStrategy",
"attributeDefinitionId": "5583",
"values": [
{
"guid": "Internal"
}
]
}
]
}
url="http://localhost:8080/ssc/api/v1/projectVersions/6855/attributes"
response = requests.put(url, headers=headers, json=json_data)
print(response.status_code)
print(response.json())
CodePudding user response:
You can not insert an array to an object directly. You should use a key.
json_data = [
{
"guid": "DevPhase",
"attributeDefinitionId": "5578",
"values": [
{
"guid": "Active"
}
]
},
{
"guid": "Accessibility",
"attributeDefinitionId": "5590",
"values": [
{
"guid": "externalpublicnetwork"
}
]
},
{
"guid": "DevStrategy",
"attributeDefinitionId": "5583",
"values": [
{
"guid": "Internal"
}
]
}
]
Try with this.