REST API - HTTP HEAD Method
2 min
the http head method lets you submit a request and receive a response with the response body omitted the purpose of the head method is to save bandwidth if you do not require the response data that is usually included in the body example if you want to determine the size of an attachment prior to downloading the file, you can use the http head method to submit your rest api get attachment request docid\ yqvqxvfzighjozrbtjkly request this allows you to determine the size of the attachment without having to download the file content example if you want to determine (approximately) how many artifacts exist for a particular filter, you can use the http head method to submit your rest api list artifacts request docid\ iabyqhikpch2vzwbezcpy request this allows you to determine the size of the response without having to download the response body python example def get attachment() \# obtain a token from our get token() function token = get token() \# of course, this id would generally come from somewhere else instead of hardcoding it project id = "220870" artifact id = "220914" attachment id = "3194" \# 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 + '/attachments/' + attachment id \# specify header parameters request header={ 'authorization' 'blueprinttoken ' + token, 'accept' 'application/xml' } \# specify the uri parameters uri parameters list={ } \# create the request uri with the uri parameters request uri = resource uri + '?' + urllib parse urlencode(uri parameters list) output requesturi(request uri) response = requests head(request uri, headers=request header) return response headers