Attachment File Upload Problem
See original GitHub issueHi,
I’m trying to add an item with an attachment to a list. Adding an item is OK, but adding an attachment is problematic. The code is below;
pnp.sp.lists.getByTitle("MyList").items.add(item).then(response => {
response.item.attachmentFiles.add("file.txt", "file content 123");
});
The error:
POST http://localhost:8383/MyList')/items(11)/AttachmentFiles/add(FileName='file.txt') 400 (Bad Request)
Fetch API cannot load http://localhost:8383/MyList')/items(11)/AttachmentFiles/add(FileName='file.txt').
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 400. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Uncaught (in promise) TypeError: Failed to fetch
Headers:
General
Request URL: http://localhost:8383/_api/web/lists/getByTitle('MyList')/items(11)/AttachmentFiles/add(FileName='file.txt')
Request Method:POST
Status Code:400 Bad Request
Remote Address:127.0.0.1:8383
Referrer Policy:no-referrer-when-downgrade
Response Headers
Connection:keep-alive
Content-Length:1048
Content-Security-Policy:default-src 'self'
Content-Type:text/html; charset=utf-8
Date:Thu, 04 May 2017 07:30:25 GMT
X-Content-Type-Options:nosniff
X-Powered-By:Express
Request Headers
accept:application/json
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:14
content-type:application/json;odata=verbose;charset=utf-8
Host:localhost:8383
Origin:http://localhost:8080
Referer:http://localhost:8080/
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.36 Safari/537.36
x-clientservice-clienttag:PnPCoreJS:2.0.4
x-requestdigest:0xB1B9800178D92F1E17AAE31002BA4F4608B210FCFFDC51F863494EEDBCD5C541781BC78F35C5103F93E4163D10CF81F64AE92C257DB818F38015C4B2CBE21D0F,04 May 2017 07:30:02 -0000
Request Payload
file content 123
I think, the proxy server responses lack Access-Control-Allow-Origin header for this type of requests.
How can we solve it?
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (8 by maintainers)
Top Results From Across the Web
Fix Files Won't Upload To Any Web Page or Email ... - YouTube
Unable to Upload Files to Any Website or email as attachment on Google Chrome or Microsoft Edge Error Not RespondingStep 1) Clear Browsing ......
Read more >Problem uploading files to web or send attachments via
Hello, I am getting an error whenever I want to upload any type of files to the web, whether it is a web...
Read more >No longer able to upload files No error message Can't close ...
I lost the ability to attach files from my computer. It acts like it's downloading but then it goes blank. No attachment.
Read more >Troubleshooting issues with uploading attachments
If you can successfully attach a file, you may have a browser extension installed that's interfering with how our attachment field is handled....
Read more >File Upload Troubleshooting | Submittable Help Center
Troubleshooting steps for problems uploading files to a form. ... Be sure the file you're trying to attach to the form is one...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@koltyakov, sorry, it was my mistake… I had put rawBodyLimitSize into _private.conf.json instead of settings object.
Now, attachment upload is fully functional… And you’re a hero! 😃
Thanks for reporting. I’ll figure it out. And come back to you. With current workload, it likely will happen on this weekend.