public async void TestCreateItemByPathFromBranch() { await this.RemoveTestItemsFromMasterAndWebAsync(); const string ItemFromBranchName = "Multiple item branch"; TestEnvironment.Item expectedItem = this.CreateTestItem(ItemFromBranchName); var request = ItemWebApiRequestBuilder.CreateItemRequestWithParentPath(this.testData.Items.CreateItemsHere.Path) .BranchId("{14416817-CDED-45AF-99BF-2DE9883B7AC3}") .ItemName(ItemFromBranchName) .Database("master") .Language("en") .Payload(PayloadType.Content) .Build(); var createResponse = await session.CreateItemAsync(request); this.testData.AssertItemsCount(1, createResponse); ISitecoreItem resultItem = createResponse[0]; this.testData.AssertItemsAreEqual(expectedItem, resultItem); var readJustCreatedItemRequest = ItemWebApiRequestBuilder.ReadItemsRequestWithId(resultItem.Id) .Database("master") .Build(); var readJustCreatedItemResponse = await this.session.ReadItemAsync(readJustCreatedItemRequest); this.testData.AssertItemsCount(1, readJustCreatedItemResponse); this.testData.AssertItemsAreEqual(expectedItem, readJustCreatedItemResponse[0]); }
public async void UploadJpgFileWithInternationalItemNameAndParentPath() { await this.RemoveAll(); //create international parent var createRequest = ItemWebApiRequestBuilder.CreateItemRequestWithParentId(this.testData.Items.UploadMediaHere.Id) .ItemTemplatePath(testData.Items.Home.Template) .ItemName("युक्रेन") .Database("master") .Build(); var createResponse = await session.CreateItemAsync(createRequest); //Assert.AreEqual(1, createResponse.ResultCount); using (var image = GetStreamFromUrl(TestEnvironment.Images.Jpeg._30x30)) { const string ItemName = "International Слава Україні ウクライナへの栄光"; const string Database = "master"; string parentPath = createResponse[0].Path.Remove(0, 23); var request = ItemWebApiRequestBuilder.UploadResourceRequestWithParentPath(parentPath) .ItemDataStream(image) .Database(Database) .ItemName(ItemName) .FileName("ク.gif") .Build(); var response = await this.session.UploadMediaResourceAsync(request); Assert.AreEqual(1, response.ResultCount); Assert.AreEqual(ItemName, response[0].DisplayName); this.AssertImageUploaded(response[0].Path, Database); } }
private async Task <ISitecoreItem> CreateItem(string itemName, ISitecoreItem parentItem = null, ISitecoreWebApiSession itemSession = null) { if (itemSession == null) { itemSession = session; } string parentPath = parentItem == null ? this.testData.Items.CreateItemsHere.Path : parentItem.Path; var request = ItemWebApiRequestBuilder.CreateItemRequestWithParentPath(parentPath) .ItemTemplatePath(testData.Items.Home.Template) .ItemName(itemName) .Build(); var createResponse = await itemSession.CreateItemAsync(request); Assert.AreEqual(1, createResponse.ResultCount); return(createResponse[0]); }
private async void SendRequest() { try { using (ISitecoreWebApiSession session = this.instanceSettings.GetSession()) { var request = ItemWebApiRequestBuilder.CreateItemRequestWithParentId(this.pathField.Text) .ItemTemplatePath("Sample/Sample Item") .ItemName(this.nameField.Text) .AddFieldsRawValuesByNameToSet("Title", titleField.Text) .AddFieldsRawValuesByNameToSet("Text", textField.Text) .Build(); this.ShowLoader(); ScItemsResponse response = await session.CreateItemAsync(request); if (response.Any()) { ISitecoreItem item = response[0]; this.CreatedItemId = item.Id; AlertHelper.ShowLocalizedAlertWithOkOption("The item created successfully", "Item path: " + item.Path); } else { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Item is not exist"); } } } catch (Exception e) { AlertHelper.ShowLocalizedAlertWithOkOption("Error", e.Message); } finally { BeginInvokeOnMainThread(delegate { this.HideLoader(); }); } }
public async void TestCreateItemByIdWithoutFieldsSet() { await this.RemoveAll(); const string ItemName = "Create by parent id"; var expectedItem = this.CreateTestItem(ItemName); var request = ItemWebApiRequestBuilder.CreateItemRequestWithParentId(this.testData.Items.CreateItemsHere.Id) .ItemTemplatePath(testData.Items.Home.Template) .ItemName(ItemName) .Database("master") .Build(); var createResponse = await session.CreateItemAsync(request); var resultItem = this.CheckCreatedItem(createResponse, expectedItem); this.GetAndCheckItem(expectedItem, resultItem); }
private async Task<ISitecoreItem> CreateItem(string itemName, ISitecoreItem parentItem = null, ISitecoreWebApiSession itemSession = null) { if (itemSession == null) { itemSession = session; } string parentPath = parentItem == null ? this.testData.Items.CreateItemsHere.Path : parentItem.Path; var request = ItemWebApiRequestBuilder.CreateItemRequestWithParentPath(parentPath) .ItemTemplatePath(testData.Items.Home.Template) .ItemName(itemName) .Build(); var createResponse = await itemSession.CreateItemAsync(request); Assert.AreEqual(1, createResponse.ResultCount); return createResponse[0]; }