Skip to content

Example POST request does not work.  #424

@hmacdope

Description

@hmacdope

The following request, directly from the example doesn't work.

import os
import tempfile
import requests

url = "https://fragalysis.diamond.ac.uk/api/download_structures/"

#data is the json you downloaded from Fragalysis
data = {"target_name":"nsp13","proteins":"nsp13-x0029_0A,nsp13-x0034_0B","event_info":False,"sigmaa_info":False,"diff_info":False,"trans_matrix_info":False,"NAN":False,"mtz_info":False,"cif_info":False,"NAN2":False,"map_info":False,"single_sdf_file":True,"sdf_info":False,"pdb_info":False,"bound_info":True,"metadata_info":True,"smiles_info":True,"static_link":False,"file_url":""}

#First get the url of the particular file using the copied json
r = requests.post("https://fragalysis.diamond.ac.uk/api/download_structures/", json=data)
if r.ok:
    #Next, use the returned url to download the actual zip file
    file_url = r.json()["file_url"]
    r = requests.get("https://fragalysis.diamond.ac.uk/api/download_structures?file_url=%s"%file_url, allow_redirects=True)
    if r.ok:
        with open(os.path.basename(file_url), mode="wb") as f:
            f.write(r.content)
else:
    print("failed")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions