# Updating draft in V3 with formdata returning error

**URL:** <https://forums.nylas.com/t/updating-draft-in-v3-with-formdata-returning-error/304>\
**Category:** Question and Answers\
**Tags:** email-api\
**Created:** [July 30, 2024, 9:23am UTC](https://forums.nylas.com/t/updating-draft-in-v3-with-formdata-returning-error/304 "2024-07-30T09:23:18Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![sheik](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sheik](https://forums.nylas.com/u/sheik)\
**Post date:** [July 30, 2024, 9:23am UTC](https://forums.nylas.com/t/updating-draft-in-v3-with-formdata-returning-error/304/1 "2024-07-30T09:23:18Z")

</div>

I am sending a request from Nylas docs as mentioned in the examples. While creating the draft with form data its working fine ,but when I try it with updating the draft it is giving below error

{  
“request\_id”: “”,  
“error”: {  
“type”: “invalid\_request\_error”,  
“message”: “NOT IMPLEMENTED”  
}  
}

i have tested with python, I am sending it as requests.

import requests  
import json

# Define your Nylas API credentials and endpoint

grant\_id = “xxxxxx”  
draft\_id = “xxxxx”  
url = f"/v3/grants/{grant\_id}/drafts/{draft\_id}"

# Set the authorization token and headers

headers = {  
“accept”: “application/json”,  
“authorization”: “Bearer xxxxxxxxxxxxxx”,  
“content-type”: “multipart/form-data”  
}

# Prepare the data for the draft update

data = {  
“bcc”: [  
{  
“email”: “brandon.carson@exam”,  
“name”: “”  
}  
],  
“body”: “Hi, Welcome to Nylas!”,  
“cc”: [  
{  
“email”: “clivescounters@exam”,  
“name”: “”  
}  
],  
“reply\_to”: [  
{  
“email”: “[healthcare.demo@example.com](mailto:healthcare.demo@example.com)”,  
“name”: “”  
}  
],  
“starred”: False,  
“thread\_id”: “1910xxxxxxxxx”,  
“subject”: “Invitation: Welcome! @ Thu Oct 28, 2021 7am - 8am (EDT) - Toronto”,  
“to”: [  
{  
“email”: “demo”,  
“name”: “”  
},  
{  
“email”: “realestate.demo”,  
“name”: “”  
}  
]  
}

files = {  
‘attachment’: open(“mails\_sample.html”, ‘rb’)  
}

# Make the PUT request to update the draft

response = requests.put(url, headers=headers, data=data, files=files)

# Check the response

if response.status\_code == 200:  
print(“Draft updated successfully:”, response.json())  
else:  
print(“Error updating draft:”, response.status\_code, response.json())

---

<div class="post-metadata">

**Author:** ![ram](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.nylas.com/ram/32/3_2.png) [@ram](https://forums.nylas.com/u/ram)\
**Post date:** [July 30, 2024, 1:32pm UTC](https://forums.nylas.com/t/updating-draft-in-v3-with-formdata-returning-error/304/2 "2024-07-30T13:32:08Z")

</div>

@sheik thanks for posting, let me take a look and follow up!

---

<div class="post-metadata">

**Author:** ![ram](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.nylas.com/ram/32/3_2.png) [@ram](https://forums.nylas.com/u/ram)\
**Post date:** [July 30, 2024, 6:18pm UTC](https://forums.nylas.com/t/updating-draft-in-v3-with-formdata-returning-error/304/3 "2024-07-30T18:18:15Z")

</div>

Hi @sheik are you using our [Python SDK for updating a draft](https://developer.nylas.com/docs/api/v3/ecc/#put-/v3/grants/-grant_id-/drafts/-draft_id-)?

That would simplify the coding side of things and ensure you have all the correct config.

Alternative, its worth trying out our [postman collection](https://www.postman.com/trynylas/nylas-api/request/bqk2dtm/update-a-draft) to debug further.

---

<div class="post-metadata">

**Author:** ![sheik](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sheik](https://forums.nylas.com/u/sheik)\
**Post date:** [July 31, 2024, 4:49am UTC](https://forums.nylas.com/t/updating-draft-in-v3-with-formdata-returning-error/304/4 "2024-07-31T04:49:53Z")

</div>

Hi @ram , It is working fine when I update a file with size below 3mb, I am trying to send a file which is greater than 3mb. As mentioned in the documentation, one can send files greater than 3mb should be sent in form data. I am trying to do same in updating a draft with attachment greater than 3mb.I am using Node Js SDK. For use cases like this I am using url directly to send form data.

---

<div class="post-metadata">

**Author:** ![ram](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.nylas.com/ram/32/3_2.png) [@ram](https://forums.nylas.com/u/ram)\
**Post date:** [July 31, 2024, 1:36pm UTC](https://forums.nylas.com/t/updating-draft-in-v3-with-formdata-returning-error/304/5 "2024-07-31T13:36:52Z")

</div>

@sheik have a look at this [related thread](https://forums.nylas.com/t/what-is-the-best-way-to-send-an-inline-attachment/169/24), let me know if it helps clarify.

---

<div class="post-metadata">

**Author:** ![VictorMonteiro7](https://avatars.discourse-cdn.com/v4/letter/v/35a633/32.png) [@VictorMonteiro7](https://forums.nylas.com/u/VictorMonteiro7)\
**Post date:** [July 31, 2024, 2:29pm UTC](https://forums.nylas.com/t/updating-draft-in-v3-with-formdata-returning-error/304/6 "2024-07-31T14:29:07Z")

</div>

Hey @ram, I have the same issue in my update draft requests.  
@sheik were you actually able to update the file with less than 3mb? To me, the request return a 200 OK, but the file wasn’t really updated.

---

<div class="post-metadata">

**Author:** ![ram](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.nylas.com/ram/32/3_2.png) [@ram](https://forums.nylas.com/u/ram)\
**Post date:** [July 31, 2024, 7:50pm UTC](https://forums.nylas.com/t/updating-draft-in-v3-with-formdata-returning-error/304/7 "2024-07-31T19:50:34Z")

</div>

@VictorMonteiro7 let me take a look, do you have a code sample that I can see the approach?

---

<div class="post-metadata">

**Author:** ![ram](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.nylas.com/ram/32/3_2.png) [@ram](https://forums.nylas.com/u/ram)\
**Post date:** [July 31, 2024, 8:11pm UTC](https://forums.nylas.com/t/updating-draft-in-v3-with-formdata-returning-error/304/8 "2024-07-31T20:11:38Z")

</div>

@VictorMonteiro7 just following up with Eng, let me circle back once I have an update.

---

<div class="post-metadata">

**Author:** ![VictorMonteiro7](https://avatars.discourse-cdn.com/v4/letter/v/35a633/32.png) [@VictorMonteiro7](https://forums.nylas.com/u/VictorMonteiro7)\
**Post date:** [July 31, 2024, 9:32pm UTC](https://forums.nylas.com/t/updating-draft-in-v3-with-formdata-returning-error/304/9 "2024-07-31T21:32:50Z")

</div>

@ram I haven’t a code example now, but I opened a topic that have relation with this topic.  
[Topic here](https://forums.nylas.com/t/how-to-remove-an-attachment-from-created-draft/263/4)

---

<div class="post-metadata">

**Author:** ![sheik](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sheik](https://forums.nylas.com/u/sheik)\
**Post date:** [August 3, 2024, 1:52pm UTC](https://forums.nylas.com/t/updating-draft-in-v3-with-formdata-returning-error/304/10 "2024-08-03T13:52:46Z")

</div>

Hey @ram got a new issue while creating a draft with multipart/formdata I am getting below error

{  
“request\_id”: “749489a6-b077-4a6b-a1fe-77851dd5f8f9”,  
“error”: {  
“type”: “provider\_error”,  
“message”: “provider returned error”,  
“provider\_error”: {  
“error”: {  
“code”: 400,  
“message”: "were unable to deserialize "  
}  
}  
}  
}  
same code was working fine 1 day before and today it is not working

---

<div class="post-metadata">

**Author:** ![sheik](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sheik](https://forums.nylas.com/u/sheik)\
**Post date:** [August 5, 2024, 5:08am UTC](https://forums.nylas.com/t/updating-draft-in-v3-with-formdata-returning-error/304/11 "2024-08-05T05:08:26Z")

</div>

Hello @ram, Its working fine for google mails , when I am trying to create draft with attachments its giving me above error in Microsoft mails.

---

<div class="post-metadata">

**Author:** ![ram](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.nylas.com/ram/32/3_2.png) [@ram](https://forums.nylas.com/u/ram)\
**Post date:** [August 6, 2024, 3:52pm UTC](https://forums.nylas.com/t/updating-draft-in-v3-with-formdata-returning-error/304/12 "2024-08-06T15:52:48Z")

</div>

@sheik as mentioned previously, waiting to hear back on this from our team, let me follow up as soon as I have an update.

---

<div class="post-metadata">

**Author:** ![stiry](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@stiry](https://forums.nylas.com/u/stiry)\
**Post date:** [August 7, 2024, 10:48am UTC](https://forums.nylas.com/t/updating-draft-in-v3-with-formdata-returning-error/304/13 "2024-08-07T10:48:35Z")

</div>

Just wanted to add I am experiencing the same behaviour with `multipart/formdata`:  
Microsoft

- Creating a draft results in 400 provider\_error

Google

- Updating a draft results in 501 NOT IMPLEMENTED

Have not tested updating a Microsoft draft as getting drafts is also in a weird spot where I don’t receive exclusive-draft threads when querying threads and any thread that should have drafts have their `draftIds` array empty.

Querying drafts gives me all drafts but I would rather not fetch them this way.

I can only assume you are still working on this and hope you fix it soon.

---

<div class="post-metadata">

**Author:** ![sheik](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sheik](https://forums.nylas.com/u/sheik)\
**Post date:** [August 7, 2024, 11:07am UTC](https://forums.nylas.com/t/updating-draft-in-v3-with-formdata-returning-error/304/14 "2024-08-07T11:07:45Z")

</div>

Hey @stiry ,

const fileStream = fs.createReadStream(file.path);  
/\*\*  
\* append file to form-data  
\* filename and contentType and knownLength are required for microsoft mails  
\*/  
form.append(‘file’, fileStream, {  
filename:file.originalname,  
contentType:file.mimetype,  
knownLength:file.size  
});

I used this to add attachments while creating a draft, Its working fine now for both google and microsoft mails while creating drafts with attachments.  
Updating attachments of the drafts is still not resolved. Waiting for the update from @ram 🙂

---

<div class="post-metadata">

**Author:** ![stiry](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@stiry](https://forums.nylas.com/u/stiry)\
**Post date:** [August 7, 2024, 12:03pm UTC](https://forums.nylas.com/t/updating-draft-in-v3-with-formdata-returning-error/304/15 "2024-08-07T12:03:02Z")

</div>

Thanks for the reply @sheik, i was not able to reproduce your success in nodejs.

But I feel it should not be possible to make these mistakes and it is Nylas’ responsibility to test these integrations before pushing us to v3 with a deadline. It is losing us faith in the product if standard functions don’t work or are documented incorrectly.

---

<div class="post-metadata">

**Author:** ![ram](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.nylas.com/ram/32/3_2.png) [@ram](https://forums.nylas.com/u/ram)\
**Post date:** [August 7, 2024, 3:22pm UTC](https://forums.nylas.com/t/updating-draft-in-v3-with-formdata-returning-error/304/16 "2024-08-07T15:22:56Z")

</div>

@stiry I’m sorry to hear this is still an issue and am working with our team to address the issue. Will keep you posted as soon as I have an update.

---

<div class="post-metadata">

**Author:** ![ram](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.nylas.com/ram/32/3_2.png) [@ram](https://forums.nylas.com/u/ram)\
**Post date:** [August 8, 2024, 9:07pm UTC](https://forums.nylas.com/t/updating-draft-in-v3-with-formdata-returning-error/304/17 "2024-08-08T21:07:35Z")

</div>

@stiry just an update, we just released a related fix, so I’m going try this out myself and will keep you posted!
