{"_id":"5679c3167b575f0d006ae1e2","tags":[],"project":"55d2023b3c74062300aee506","__v":1,"user":{"_id":"55d201fe945e481700afbb19","username":"","name":"Abhik Pramanik"},"metadata":{"title":"","description":"","image":[]},"createdAt":"2015-12-22T21:39:34.274Z","changelog":[{"_id":"5679c3167b575f0d006ae1e5","update":"[Reference Attachment in RFI](doc:reference-attachment-in-rfi)","type":"added"},{"_id":"5679c3167b575f0d006ae1e4","update":"[Reference Photo in RFI](doc:reference-photo-in-rfi)","type":"added"},{"_id":"5679c3167b575f0d006ae1e3","update":"[Upload Attachment to Project](doc:upload-attachment-to-project)","type":"added"},{"_id":"5679c44376cd370d003c1191","update":"[Complete Attachment Upload to Project](doc:complete-attachment-upload-to-project)","type":"added"},{"_id":"5679c44376cd370d003c1190","update":"API writes (POST, PUT, PATCH, DELETE) now have a limit of 500 per hour per key","type":"added"},{"_id":"5679c44376cd370d003c118f","update":"","type":"added"}],"body":"[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/v9ehoM1PQ5mxcjZN112x_santa.png\",\n        \"santa.png\",\n        \"3056\",\n        \"1234\",\n        \"#a18368\",\n        \"\"\n      ],\n      \"caption\": \"(Tony Lewis / Getty Images)\",\n      \"border\": false,\n      \"sizing\": \"smart\"\n    }\n  ]\n}\n[/block]\nHappy holidays PlanGrid developers! We're giving you a major beta release for Christmas that adds the ability to upload attachments and reference photos and attachments on RFIs. \n\nIn order to reference a photo or attachment, it must be an existing record on the project. In this release, you can upload attachments via [Upload Attachment to Project](doc:upload-attachment-to-project); uploading photos will be released in January. We strongly recommend reading the [File Uploads section](doc:file-uploads) to understand the three step process of uploading files via the API. \n\nOnce you've uploaded the attachment, use its unique identifier to add it as a reference on the RFI via [Reference Attachment in RFI](doc:reference-attachment-in-rfi). Add a photo as a reference via [Reference Photo in RFI](doc:reference-photo-in-rfi).\n\nTo help you get started, we've written some example code in python that takes a PDF file, uploads it to a project as an attachment, and then references it on the first RFI in the project:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import requests\\nfrom collections import OrderedDict\\n\\napi_prefix = 'https://io.plangrid.com'\\napi_key = 'API_KEY'\\nversion_headers = {'Accept': 'application/vnd.plangrid+json; version=1'}\\n\\ndef get_first_project_uid():\\n    # Get the UID of the first project returned from the API\\n    projects_url = '{}/projects'.format(api_prefix)\\n    response = requests.get(projects_url, auth=(api_key, None), headers=version_headers)\\n    projects = response.json()['data']\\n    first_project_uid = projects[0]['uid']\\n    return first_project_uid\\n\\ndef request_attachment_upload(project_uid):\\n    attachment_upload_url = '{}/projects/{}/attachments/uploads'.format(api_prefix, project_uid)\\n    headers = {'content-type': 'application/json'}\\n    headers.update(version_headers)\\n    data = {'content_type': 'application/pdf', 'name': '0001-060000-1.pdf', 'folder': 'Submittals'}\\n    response = requests.post(attachment_upload_url, json=data, headers=headers,\\n                             auth=(api_key, None))\\n    file_upload_info = response.json()\\n    return file_upload_info\\n\\ndef upload_file(file_upload_info):\\n    url = file_upload_info['aws_post_form_arguments']['action']\\n    fields = file_upload_info['aws_post_form_arguments']['fields']\\n    fields = OrderedDict([(kv['name'], kv['value']) for kv in fields])\\n    files = OrderedDict([('file', open('Submittal_0001-060000-1.pdf'))])\\n    response = requests.post(url, files=files, data=fields)\\n    return response.json()\\n\\ndef get_first_rfi_uid(project_uid):\\n    # Get the UID of the first RFI returned from the API\\n    rfis_url = '{}/projects/{}/rfis'.format(api_prefix, project_uid)\\n    response = requests.get(rfis_url, auth=(api_key, None), headers=version_headers)\\n    rfis = response.json()['data']\\n    first_rfi_uid = rfis[0]['uid']\\n    return first_rfi_uid\\n\\ndef reference_attachment(rfi_uid, attachment_uid):\\n    reference_attachment_url = '{}/projects/{}/rfis/{}/attachments'.format(api_prefix, project_uid, rfi_uid)\\n    data = {'attachment_uid': attachment_uid}\\n    response = requests.post(reference_attachment_url, json=data, auth=(api_key, None), headers=version_headers)\\n    return response.text\\n\\n# Upload Attachment\\n## Get project and RFI uid\\nproject_uid = get_first_project_uid()\\nrfi_uid = get_first_rfi_uid(project_uid)\\n\\n## Step 1\\nfile_upload_info = request_attachment_upload(project_uid=project_uid)\\n\\n## Step 2 (3 is handled automatically)\\nnew_attachment = upload_file(file_upload_info=file_upload_info)\\n\\n## Step 3\\nprint reference_attachment(rfi_uid, new_attachment['uid'])\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]\nIn addition to these new endpoints, we've set a limit on the number of writes (POST, PUT, PATCH, DELETE) to 500 per hour per API key. If you feel you'll need to do more, please email [Abhik](mailto:abhik@plangrid.com) and we'll work something out.\n\nMerry Christmas and a Happy New Year from the PlanGrid API team.","slug":"100-beta-2015-12-22","title":"1.0.0 Beta 2015-12-22"}

1.0.0 Beta 2015-12-22


[block:image] { "images": [ { "image": [ "https://files.readme.io/v9ehoM1PQ5mxcjZN112x_santa.png", "santa.png", "3056", "1234", "#a18368", "" ], "caption": "(Tony Lewis / Getty Images)", "border": false, "sizing": "smart" } ] } [/block] Happy holidays PlanGrid developers! We're giving you a major beta release for Christmas that adds the ability to upload attachments and reference photos and attachments on RFIs. In order to reference a photo or attachment, it must be an existing record on the project. In this release, you can upload attachments via [Upload Attachment to Project](doc:upload-attachment-to-project); uploading photos will be released in January. We strongly recommend reading the [File Uploads section](doc:file-uploads) to understand the three step process of uploading files via the API. Once you've uploaded the attachment, use its unique identifier to add it as a reference on the RFI via [Reference Attachment in RFI](doc:reference-attachment-in-rfi). Add a photo as a reference via [Reference Photo in RFI](doc:reference-photo-in-rfi). To help you get started, we've written some example code in python that takes a PDF file, uploads it to a project as an attachment, and then references it on the first RFI in the project: [block:code] { "codes": [ { "code": "import requests\nfrom collections import OrderedDict\n\napi_prefix = 'https://io.plangrid.com'\napi_key = 'API_KEY'\nversion_headers = {'Accept': 'application/vnd.plangrid+json; version=1'}\n\ndef get_first_project_uid():\n # Get the UID of the first project returned from the API\n projects_url = '{}/projects'.format(api_prefix)\n response = requests.get(projects_url, auth=(api_key, None), headers=version_headers)\n projects = response.json()['data']\n first_project_uid = projects[0]['uid']\n return first_project_uid\n\ndef request_attachment_upload(project_uid):\n attachment_upload_url = '{}/projects/{}/attachments/uploads'.format(api_prefix, project_uid)\n headers = {'content-type': 'application/json'}\n headers.update(version_headers)\n data = {'content_type': 'application/pdf', 'name': '0001-060000-1.pdf', 'folder': 'Submittals'}\n response = requests.post(attachment_upload_url, json=data, headers=headers,\n auth=(api_key, None))\n file_upload_info = response.json()\n return file_upload_info\n\ndef upload_file(file_upload_info):\n url = file_upload_info['aws_post_form_arguments']['action']\n fields = file_upload_info['aws_post_form_arguments']['fields']\n fields = OrderedDict([(kv['name'], kv['value']) for kv in fields])\n files = OrderedDict([('file', open('Submittal_0001-060000-1.pdf'))])\n response = requests.post(url, files=files, data=fields)\n return response.json()\n\ndef get_first_rfi_uid(project_uid):\n # Get the UID of the first RFI returned from the API\n rfis_url = '{}/projects/{}/rfis'.format(api_prefix, project_uid)\n response = requests.get(rfis_url, auth=(api_key, None), headers=version_headers)\n rfis = response.json()['data']\n first_rfi_uid = rfis[0]['uid']\n return first_rfi_uid\n\ndef reference_attachment(rfi_uid, attachment_uid):\n reference_attachment_url = '{}/projects/{}/rfis/{}/attachments'.format(api_prefix, project_uid, rfi_uid)\n data = {'attachment_uid': attachment_uid}\n response = requests.post(reference_attachment_url, json=data, auth=(api_key, None), headers=version_headers)\n return response.text\n\n# Upload Attachment\n## Get project and RFI uid\nproject_uid = get_first_project_uid()\nrfi_uid = get_first_rfi_uid(project_uid)\n\n## Step 1\nfile_upload_info = request_attachment_upload(project_uid=project_uid)\n\n## Step 2 (3 is handled automatically)\nnew_attachment = upload_file(file_upload_info=file_upload_info)\n\n## Step 3\nprint reference_attachment(rfi_uid, new_attachment['uid'])", "language": "python" } ] } [/block] In addition to these new endpoints, we've set a limit on the number of writes (POST, PUT, PATCH, DELETE) to 500 per hour per API key. If you feel you'll need to do more, please email [Abhik](mailto:abhik@plangrid.com) and we'll work something out. Merry Christmas and a Happy New Year from the PlanGrid API team.
added
[Reference Attachment in RFI](doc:reference-attachment-in-rfi)
added
[Reference Photo in RFI](doc:reference-photo-in-rfi)
added
[Upload Attachment to Project](doc:upload-attachment-to-project)
added
[Complete Attachment Upload to Project](doc:complete-attachment-upload-to-project)
added
API writes (POST, PUT, PATCH, DELETE) now have a limit of 500 per hour per key