REST API - HTTP DELETE Method

Updated by Stefenie Stockbridge

What should I do if I cannot use the DELETE method?

In some environments, the firewall may not support the DELETE method, or the DELETE method may be disabled.

It is possible to use HTTP POST method instead of HTTP DELETE. To submit information using the HTTP POST method instead of HTTP DELETE, you must add the following information to the request header to override the POST method:

X-HTTP-Method-Override: DELETE

Python Example

def delete_artifact():
# obtain a token from our get_token() function
token = get_token()

# Of course, this IDs would generally come from somewhere else instead of hardcoding it.
project_id = "115387"
artifact_id = "115933"

# build the resource uri for listing artifacts in a given project
resource_uri = 'https://production.blueprintcloud.com/api/v1/projects/' + project_id + '/artifacts/' + artifact_id

# specify header parameters
request_header={
'Authorization' : 'BlueprintToken ' + token,
'Accept' : 'application/json',
'X-HTTP-Method-Override': 'DELETE'
}

# create the request uri (add params if it's needed)
request_uri = resource_uri

# create the request body
request_body = ""

# submit the request using HTTP POST method
response = requests.post(request_uri, request_body, headers=request_header)
return response


How did we do?