Pnpjs: HubSiteData - response type

Created on 25 Mar 2019  路  10Comments  路  Source: pnp/pnpjs

Category

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

Version

Please specify what version of the library you are using: [1.3.1]

Please specify what version(s) of SharePoint you are targeting: [Online, dedicated tenant]

Expected / Desired Behavior / Question

The hubSiteData method in webs.ts class expect the IHubSiteData result. The result object does not match the REST API definition.

Observed Behavior

The call returns a string value instead of IHubSiteData value.

Steps to Reproduce

You need to have a site collection (child) connected to the hub site collection. If you call the await sp.web.hubSiteData(false); code in the context of child site connection, the result is string, not an object.

Comments

Hello, I checked both categories (Question & Bug) because I am not sure, what should be the desired behavior. The response IHubSiteData count with properties like Url, but the REST API definition use the url property (I did not found any mapping on PnP JS side).
On the other site the output from /_api/web/HubSiteData(true) call did not mach the REST API definition as well :( (I am working on dedicated SharePoint Online instance) - the REST call returns output like this:

{
   "d": {
      "HubSiteData": {
         "headerEmphasis": null,
         "themeKey": "...",
         "name": "...",
         "url": "HUB SITE URL",
         "logoUrl": null,
         "usesMetadataNavigation": false,
         "megaMenuEnabled": false,
         "navigation": [
            ...NAVIGATION DATA...
         ],
         "siteDesignId": "00000000-0000-0000-0000-000000000000",
         "requiresJoinApproval": false
      }
   }
}

The same call with PnP JS returns string:

"{"headerEmphasis":null,"themeKey":"...","name":"...","url":"HUB SITE URL","logoUrl":null,"usesMetadataNavigation":false,"megaMenuEnabled":false,"navigation":[...NAVIGATION DATA...],"siteDesignId":"00000000-0000-0000-0000-000000000000","requiresJoinApproval":false}"
code fixed bug

All 10 comments

The shape of response can be different depending on OData mode (verbose/minimalmetadata/nometadata), however we abstract such things away. Confirming that web.hubSiteData response is currently not parsed string, which probably was not the case 5 months ago when a method was added to the library. Looks like a bug for me which we definitely can fix sooner.

@koltyakov - were you working on this one?

Have not started yet =(

Cool, no worries, I will have a look now, just didn't want to duplicate work

Fixed this and added to PR #581.

For whatever reason the value is now a string vs the object so added a JSON.parse.

Thanks for taking care of this issue.

I did not find any update in the IHubSiteData -> the JSON.parse() returns a different object as I described in the description (the IHubSiteData use first letter in uppercase, the REST response return all properties in lowercase)

So you are reporting two issues? The one you described was that the result is coming back as a string?

Yes, mentioned in the Comments section

Hi @patrick-rodgers, would it be possible to remove "fixed" status as the interface has not been fixed?
Thanks

Have had time to circle back and update the interface. Should now match what is coming back from the service.

Was this page helpful?
0 / 5 - 0 ratings