Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a file with some fields throws an error #160

Closed
SemonnomeS opened this issue Jan 8, 2021 · 13 comments
Closed

Creating a file with some fields throws an error #160

SemonnomeS opened this issue Jan 8, 2021 · 13 comments

Comments

@SemonnomeS
Copy link

In case when i create a new file without fields, everything works nice. But when i provide some fileds ( even when i pass empty fileds object ) request throws an error. I will provide image bellow.

image

My code, which is identical to yours on https://aymkdn.github.io/SharepointPlus/files.html#createFile

image

@Aymkdn
Copy link
Owner

Aymkdn commented Jan 8, 2021

Can you check the Network tab of your web console? To see what the server returns to the request.

@Aymkdn
Copy link
Owner

Aymkdn commented Jan 8, 2021

The way it works:

  1. It will first create the file (without info because we cannot do it in one request);
  2. It will check the uri returned by the server once the file has been created;
  3. It will use it to figure out the item ID;
  4. It will do a $SP().list().update() using the item ID and the provided fields.

@SemonnomeS
Copy link
Author

It gives an error 409 (conflict) in network tab and than 401 (unauthorized). But without fields i can save file and also i can update manually ( i have full permissions ).

@Aymkdn
Copy link
Owner

Aymkdn commented Jan 8, 2021

Do you see the request that is done using the uri returned by the server after the file's creation? It might be where the 401 error is returned?

Is there a conflict because the file is checked out? Or something similar?

@SemonnomeS
Copy link
Author

In the case that it makes two requests first creation of file than update. It should save that file without fileds i think. But nothing is saved. Currently i am saving three files in a row.

image

@SemonnomeS
Copy link
Author

Sometimes it is 500, sometimes it is error 409
image

@Aymkdn
Copy link
Owner

Aymkdn commented Jan 8, 2021

It's hard to say what's going on... You should try with one file at a time to see if it works, and clear the network tab before processing, then click on each request that is sent to verify the content of the request and the response from the server.

@SemonnomeS
Copy link
Author

Thank you for the support. I will try to make an update on my own for each file once files are saved without fileds. Can you please tell me, where/how can i pass overwrite=false for the files creation ?

@Aymkdn
Copy link
Owner

Aymkdn commented Jan 8, 2021

where/how can i pass overwrite=false for the files creation

It's actually a good question. It's hardcoded and not a parameter as of today... It's something I could add in the next release. I can try to release a new version later today if it helps...

@SemonnomeS
Copy link
Author

Yes it would help a lot. Thank you for your fast response and good help.

@Aymkdn
Copy link
Owner

Aymkdn commented Jan 8, 2021

FYI I've just tried on my side (Sharepoint 2013 OnPrem) and three requests are sent:
image

I'm working on the new release right now.

@SemonnomeS
Copy link
Author

Currently my sharepoint is running locally using proxy, and i think maybe that is why the request (updating) which comes after saving file doesnt work because base url is not provided for the second request.

@Aymkdn
Copy link
Owner

Aymkdn commented Jan 8, 2021

The new version (v6.1.3) has just been published: changelog

There is now an option overwrite (https://aymkdn.github.io/SharepointPlus/files.html#createFile) – if the file already exists it will thrown an error.

@Aymkdn Aymkdn closed this as completed Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants