Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Asset addition using web api c#

Avatar

Avatar
Ignite 1
Level 1
binayp94927267
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Ignite 1
Give Back
View profile

Avatar
Ignite 1
Level 1
binayp94927267
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Ignite 1
Give Back
View profile
binayp94927267
Level 1

10-05-2018

I am at present writing some tests for Azure Experience Manager ,in which i need to upload huge data like jpg , Tiff ,Zip .. etc files.

So To add that I am using Api POST call using my C# Test Project in visual Studio  .

I am using Http Client with HttpContent as MultipartFormDataContent , so it adds the Asset inside my Custom Folder in CRXDE Lite

the Url is Like this "http://localhost:4502/crx/de/index.jsp#/content/dam/AemTest ".

But the Structure it shows is, it add a FileContent e.g abc.jpg and child Node it adds jcr:content where some metadata appears . Inside Tool-> CRXDE lite

Note : jcr:primaryType =  nt:file

But when Looked inside Assets Folder , it shows Empty . i.e Navigation->Asset-> Files->AemTest

Now when I am Tring to add Manually the Same Asset

it shows an Asset added as  jcr:primaryType = dam:Asset inside CRXDE Lite

also the Structure it comes as first it creates a Node Named  eg. "abc.jpg" then in child Node jcr:content then child node metadata, rendition folder, related node

How can I achieve this by using Api calls like POST,GET ,PUT .

Replies

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

10-05-2018

Please refer to this document that describes the Asset HTTP API -- Assets HTTP API

Avatar

Avatar
Ignite 1
Level 1
binayp94927267
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Ignite 1
Give Back
View profile

Avatar
Ignite 1
Level 1
binayp94927267
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Ignite 1
Give Back
View profile
binayp94927267
Level 1

14-05-2018

Referring to document , Now I am Trying to Update the Metadata for a Asset e.g bird.jpg

So Below is the Code I am Referring to

HttpWebRequest httpWReq = (HttpWebRequest)WebRequest.Create(http://localhost:4502/content/AemTest/bird.jpg);

NetworkCredential nc = new NetworkCredential("admin", "admin");

         httpWReq.Method = "PUT";

        httpWReq.Credentials = nc;

        httpWReq.ContentType = "application/json";

        String postData = "{\"class\":\"asset\", \"properties\":{\"dc:title\":\"My Asset\"}}";

            using (var streamWriter = new StreamWriter(httpWReq.GetRequestStream()))

            {

                streamWriter.Write(postData);

                streamWriter.Flush();

                streamWriter.Close();

            }

HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse();

But everytime it returns "NO CONTENT". and the Asset is not getting updated .