sinner
sinner

Reputation: 513

Create folder inside folder OneDrive in iOS

OneDrive has the option to create a folder from iOS application. I have created it with the help of the following method:

[self.liveClient postWithPath:@"me/skydrive" dictBody:newFolder delegate:self userState:@"create folder"];
newFolder = NSDictionary with folder details including folder name.

Folder name I created here is xyz.

Now when I tried to create a sub folder inside this particular folder with the following path:

[self.liveClient postWithPath:@"me/skydrive/xyz" dictBody:newFolder delegate:self userState:@"create folder"];

Here xyz is the now the existing folder inside one drive.

But now it throws me the error below:

LiveServicesErrorDomain error 5.

Upvotes: 0

Views: 419

Answers (1)

sinner
sinner

Reputation: 513

Here is the solution.

Step1:

First create the folder on the root of the one drive through following method:

[self.liveClient postWithPath:@"me/skydrive" dictBody:newFolder delegate:self userState:@"create folder"];

newFolder = NSDictionary with folder details including folder name. Name the subfolder name anything let say abc

This will create xyz folder on the root of the one drive cloud.

Step2:

Fetch the path of the xyz folder created on the one drive cloud. To do so use the following query:

[self.liveClient getWithPath:@"me/skydrive/files" delegate:self userState:@"me/skydrive/files"];

In response you will receive data in the form of JSON format which actually a array of dictionaries. For dictionary specific to xyz folder there will be a key name as "id" whose value will be the path to reach inside xyz folder.

Step3:

Now, to create a subfolder run the following query:

[self.liveClient postWithPath:id dictBody:newFolder delegate:self userState:@"create subfolder"];

newFolder = NSDictionary with folder details including folder name.

id = id is the path of the folder xyz fetched in the step2.

This will create abc subfolder inside xyz folder on the one drive cloud.

Upvotes: 2

Related Questions