Pnpjs: Expose tenant app catalog URL

Created on 21 Mar 2019  路  8Comments  路  Source: pnp/pnpjs

Category

  • [x] Enhancement
  • [ ] Bug
  • [ ] Question
  • [ ] Documentation gap/issue

Version

Library: 1.2.8

SharePoint: SharePoint Online

Expected / Desired Behavior / Question

Not sure if I missed it looking through the documentation, but it'd be great if the SP_TenantSettings_Current endpoint was exposed through this library. I find myself having to manually call the endpoint to get the URL of the tenant app catalog site collection, while doing everything else within the library.

My current use case is adding a list to the tenant app catalog site collection without knowing the URL or site name.

code complete enhancement

Most helpful comment

Gotcha, thanks @lworkman & @tavikukko for some reason it just wasn't clicking for me. Sure we can look at adding something for this. Thanks for the explanation and the idea!

All 8 comments

We have the getAppCatalog and getSiteCollectionAppCatalog methods available, is that what you are looking for?

@patrick-rodgers those give me access to the AppCatalog object, but what I need is the Web that the app catalog is in. The SP_TenantSettings_Current endpoint gives me the URL of the App Catalog site collection, and I can then use that to access the web, but I'm just hoping to do something like that through this library.

does creating a new web with that url not work?

import { Web } from "@pnp/sp";

const web = new Web("{The url of the web}");

Edit: I am not understanding what you are trying to do. If you could pseudo code it or otherwise give me an example we can always look at adding things.

There is endpoint https://contoso.sharepoint.com/_api/SP_TenantSettings_Current which returns:
```xml

xmlns="http://www.w3.org/2005/Atom"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns:georss="http://www.georss.org/georss"
xmlns:gml="http://www.opengis.net/gml">
https://contoso.sharepoint.com/_api/SP_TenantSettings_Current


<br /> <updated>2019-03-21T21:23:14Z</updated><br /> <author><br /> <name /><br /> </author><br /> <content type="application/xml"><br /> <m:properties><br /> <d:CorporateCatalogUrl><a rel="nofollow noopener" target="_blank" href="https://contoso.sharepoint.com/sites/appcatalog">https://contoso.sharepoint.com/sites/appcatalog</a></d:CorporateCatalogUrl><br /> </m:properties><br /> </content><br /> </entry></p> </div> <div class="card-footer"> <div class="row"> <div class="col"> <img src="https://avatars.githubusercontent.com/u/2223355?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="tavikukko picture"> <strong>tavikukko</strong> <span class="text-muted ml-1">on 21 Mar 2019</span> </div> <div class="col text-right"> </div> </div> </div> </div> <div class="card card-custom mb-4"> <div class="card-body pt-3 pb-3 markdown"> <p>@patrick-rodgers Ideally, the library would expose a function (like <code>getTenantAppCatalogWeb</code>) that returned the <code>Web</code> of the app catalog without having to know the url. It would work similarly to <code>getAppCatalog</code>, but return the entire <code>Web</code> instead of just the <code>AppCatalog</code>.</p> <p>The URL I'm referencing (which <strong>@tavikukko</strong> posted the response from) gives you the App Catalog site collection URL. This is why I know it's possible.</p> <p>At it's most basic, I'm asking for a way to hit this endpoint through this library. Right now, I have to do something like this:</p> <pre><code class="prettyprint">const appCatalogWeb = new Web( await fetch(https://contoso.sharepoint.com/_api/SP_TenantSettings_Current) .then(res => res.json()) .then(body => body.CorporateCatalogUrl) ) </code></pre> </div> <div class="card-footer"> <div class="row"> <div class="col"> <img src="https://avatars.githubusercontent.com/u/12467662?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="lworkman picture"> <strong>lworkman</strong> <span class="text-muted ml-1">on 21 Mar 2019</span> </div> <div class="col text-right"> </div> </div> </div> </div> <div class="card card-custom mb-4"> <div class="card-body pt-3 pb-3 markdown"> <p>Gotcha, thanks <strong>@lworkman</strong> & <strong>@tavikukko</strong> for some reason it just wasn't clicking for me. Sure we can look at adding something for this. Thanks for the explanation and the idea!</p> </div> <div class="card-footer"> <div class="row"> <div class="col"> <img src="https://avatars.githubusercontent.com/u/13154702?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="patrick-rodgers picture"> <strong>patrick-rodgers</strong> <span class="text-muted ml-1">on 22 Mar 2019</span> </div> <div class="col text-right"> 🚀<span class="ml-2 mr-3">1</span> 👍<span class="ml-2 mr-3">1</span> </div> </div> </div> </div> <div class="card card-custom mb-4"> <div class="card-body pt-3 pb-3 markdown"> <p>Done, will be immediately off the sp import:</p> <pre><code class="prettyprint">sp.getTenantAppCatalogWeb().then(r => { r.get().then(t => { console.log(JSON.stringify(t, null, 2)); }); }); </code></pre> <p>Have a look at the code, things like this make a great first PR as there isn't too much to it.</p> </div> <div class="card-footer"> <div class="row"> <div class="col"> <img src="https://avatars.githubusercontent.com/u/13154702?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="patrick-rodgers picture"> <strong>patrick-rodgers</strong> <span class="text-muted ml-1">on 26 Mar 2019</span> </div> <div class="col text-right"> 👍<span class="ml-2 mr-3">1</span> </div> </div> </div> </div> <div class="card card-custom mb-4"> <div class="card-body pt-3 pb-3 markdown"> <p>Thank you for the fast PR! Really appreciate it.</p> </div> <div class="card-footer"> <div class="row"> <div class="col"> <img src="https://avatars.githubusercontent.com/u/12467662?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="lworkman picture"> <strong>lworkman</strong> <span class="text-muted ml-1">on 26 Mar 2019</span> </div> <div class="col text-right"> </div> </div> </div> </div> </div> <div class="col-12"> <div class="card card-custom mb-4"> <div class="card-body pt-3 pb-3 markdown text-center helpful"> <div class="title">Was this page helpful?</div> <div class="mt-1" onMouseLeave="rating(423515213, 0);"> <i class="fas fa-star inactive" id="star-1" onMouseOver="rating(423515213, 1);" onclick="rate(423515213, 1);"></i> <i class="fas fa-star inactive" id="star-2" onMouseOver="rating(423515213, 2);" onclick="rate(423515213, 2);"></i> <i class="fas fa-star inactive" id="star-3" onMouseOver="rating(423515213, 3);" onclick="rate(423515213, 3);"></i> <i class="fas fa-star inactive" id="star-4" onMouseOver="rating(423515213, 4);" onclick="rate(423515213, 4);"></i> <i class="fas fa-star inactive" id="star-5" onMouseOver="rating(423515213, 5);" onclick="rate(423515213, 5);"></i> </div> <div class="description text-small"><span id="rating-val">0</span> / 5 - <span id="rating-count">0</span> ratings</div> </div> </div> <div class="mb-4"> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3835332123789605" data-ad-slot="3452512275" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> </div> </div> <div class="col-12 col-lg-4"> <div id="ph-above-related"></div> <div class="card card-custom issue-box"> <div class="card-body pt-3 pb-5"> <h2 class="mb-4">Related issues</h2> <div> <strong> <a href="/pnpjs/341157108/unable-to-perform-multiple-operations-with-the-same-file-in">Unable to perform multiple operations with the same file in one batch.</a> </strong> </div> <div class="text-muted text-small mt-2"> <img src="https://avatars.githubusercontent.com/u/17036219?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="AJIXuMuK picture"> <strong class="pr-1" dir="ltr">AJIXuMuK</strong>  路  <span class="px-1" dir="ltr">3</span><span>Comments</span> </div> <hr /> <div> <strong> <a href="/pnpjs/389987466/json-stringify-converting-circular-structure-to-json-data">JSON.stringify Converting circular structure to JSON Data when LogLevel.Verbose and using batching with getPaged()</a> </strong> </div> <div class="text-muted text-small mt-2"> <img src="https://avatars.githubusercontent.com/u/10885472?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="bogeorge picture"> <strong class="pr-1" dir="ltr">bogeorge</strong>  路  <span class="px-1" dir="ltr">3</span><span>Comments</span> </div> <hr /> <div> <strong> <a href="/pnpjs/365674575/pnp-sp-ensure-works-on-workbench-fails-when-deployed-to">pnp/sp ensure works on workbench, fails when deployed to tenant </a> </strong> </div> <div class="text-muted text-small mt-2"> <img src="https://avatars.githubusercontent.com/u/43765678?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="Holden15 picture"> <strong class="pr-1" dir="ltr">Holden15</strong>  路  <span class="px-1" dir="ltr">3</span><span>Comments</span> </div> <hr /> <div> <strong> <a href="/pnpjs/319859018/is-new-repository-has-option-to-create-list-items-in">Is new repository has option to create list items in directly in folder?</a> </strong> </div> <div class="text-muted text-small mt-2"> <img src="https://avatars.githubusercontent.com/u/9005752?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="ahsanranjha picture"> <strong class="pr-1" dir="ltr">ahsanranjha</strong>  路  <span class="px-1" dir="ltr">3</span><span>Comments</span> </div> <hr /> <div> <strong> <a href="/pnpjs/355906074/unable-to-add-news-webpart-programatically-in-modern-page">Unable to add "News" webpart programatically in modern page. </a> </strong> </div> <div class="text-muted text-small mt-2"> <img src="https://avatars.githubusercontent.com/u/10346150?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="pavan2920 picture"> <strong class="pr-1" dir="ltr">pavan2920</strong>  路  <span class="px-1" dir="ltr">3</span><span>Comments</span> </div> </div> </div> <div class="sticky-top pt-4"> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3835332123789605" data-ad-slot="3919948963" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <div id="ph-below-related-2" class="mt-4"> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3835332123789605" data-ad-slot="3919948963" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> </div> <div class="col-12 col-lg-4"> </div> </div> <div class="skyscraper-container"> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3835332123789605" data-ad-slot="7879185320" data-ad-format="vertical" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div class="mt-5 spacer"></div> <footer class="mt-5 pb-2 py-4 text-center mt-auto"> <div class="container"> <a class="navbar-brand logo mr-5" href="/"> <img src="/assets/img/logo.svg" width="40" height="40" alt="bleepingcoder logo"> bleeping<strong>coder</strong> </a> <div class="mt-4"> bleepingcoder.com uses publicly licensed GitHub information to provide developers around the world with solutions to their problems. We are not affiliated with GitHub, Inc. or with any developers who use GitHub for their projects. We do not host any of the videos or images on our servers. All rights belong to their respective owners. </div> <div> Source for this page: <a href="https://www.github.com/pnp/pnpjs/issues/570" rel="nofollow noreferrer" target="_blank">Source</a> </div> </div> <hr class="mb-5 mt-5"> <div class="container"> <div class="row"> <div class="col-sm-4 col-lg mb-sm-0 mb-5"> <strong>Popular programming languages</strong> <ul class="list-unstyled mb-0 mt-2"> <li class="mb-2"> <a href="/python" dir="ltr">Python</a> </li> <li class="mb-2"> <a href="/javascript" dir="ltr">JavaScript</a> </li> <li class="mb-2"> <a href="/typescript" dir="ltr">TypeScript</a> </li> <li class="mb-2"> <a href="/cpp" dir="ltr">C++</a> </li> <li class="mb-2"> <a href="/csharp" dir="ltr">C#</a> </li> </ul> </div> <div class="col-sm-4 col-lg mb-sm-0 mb-5"> <strong>Popular GitHub projects</strong> <ul class="list-unstyled mb-0 mt-2"> <li class="mb-2"> <a href="/microsoft/vscode" dir="ltr">vscode</a> </li> <li class="mb-2"> <a href="/numpy/numpy" dir="ltr">numpy</a> </li> <li class="mb-2"> <a href="/ant-design/ant-design" dir="ltr">ant-design</a> </li> <li class="mb-2"> <a href="/mui-org/material-ui" dir="ltr">material-ui</a> </li> <li class="mb-2"> <a href="/vercel/next-js" dir="ltr">next.js</a> </li> </ul> </div> <div class="col-sm-4 col-lg mb-0"> <strong>More GitHub projects</strong> <ul class="list-unstyled mb-0 mt-2"> <li class="mb-2"> <a href="/rust-lang/rust" dir="ltr">rust</a> </li> <li class="mb-2"> <a href="/moment/moment" dir="ltr">moment</a> </li> <li class="mb-2"> <a href="/yarnpkg/yarn" dir="ltr">yarn</a> </li> <li class="mb-2"> <a href="/mozilla/pdf-js" dir="ltr">pdf.js</a> </li> <li class="mb-2"> <a href="/JuliaLang/julia" dir="ltr">julia</a> </li> </ul> </div> </div> </div> <hr class="mb-5 mt-5"> <div class="container text-muted"> 漏 2026 bleepingcoder.com - <a href="/bleeps" rel="nofollow">Contact</a><br /> By using our site, you acknowledge that you have read and understand our <a href="/cookies" rel="nofollow">Cookie Policy</a> and <a href="/privacy" rel="nofollow">Privacy Policy</a>. </div> </footer> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha256-4+XzXVhsDmqanXGHaHvgh1gMQKX40OUvDEBTu8JcmNs=" crossorigin="anonymous"></script> <script async src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script> <!--<script defer type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5fb2db66acbd74b2"></script>--> <script type="text/javascript" src="/assets/js/main.js"></script> <script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script></body> </html>