2

I am having some of the Site Content Types available in my SharePoint 2013 site. Now I want to assign this Site Content Types to my Document Library using REST API.

I have tried code from here and it worked perfectly. But the only problem is it required Content Type ID to associate and I am just having Site Content Types name.

So I just want to know is there any REST end point available through which I can associate my Site Content Type to my library using Name instead of ID?

I am bound to use REST API only.

6

You can get content type id from its name. Just you have to use $filter.

"/_api/web/AvailableContentTypes?$select=Name,Id,StringId&$filter=Name eq 'Your CT Name'"

Just make a GET request to the above end-point.

PS: Id is a object. So better you can consider to $select StringId in your query.

  • 2
    :-) Got it worked. My knowledge is limited in REST API... – Aakash Maurya Jul 29 '16 at 8:42
  • 1
    You have asked a nice question! I did not know before about this end-point. After seeing your questing, I have just explored it using my REST client. You can also use REST client to explore REST API. – Atish Dipongkor - MVP Jul 29 '16 at 8:47
  • 2
    Hi @AakashMorya, I have made a REST Client. You can check if it can help you to explore REST API. chrome.google.com/webstore/detail/sp-rest-client/… – Atish Dipongkor - MVP Aug 27 '16 at 8:32
  • Will definitely check :-) – Aakash Maurya Aug 27 '16 at 8:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.