2

Till drop 6 i was able to get user properties using Rest call method as below.

public getUserProperties(): Promise { return this.context.httpClient.get( ${this.context.pageContext.web.absoluteUrl}/_api/SP.UserProfiles.PeopleManager/GetMyProperties) .then((response: Response) => { return response.json(); }); }

now with new Release RC0, this.context.httpClient.get method is asking for one Extra Parameter which is called configuration of Type "HttpClientConfiguration". here i found the method defintion on web. I am not sure what paramter need to pass for this, as description it said "normally this should be the latest version number from HttpClientConfigurations". i would like to know what is the latest version of HttpClientConfigurations.Thanks in Advance.

1

1 Answer 1

1

Lots of breaking changes introduced in RCO:

Use it as below:

import {
  SPHttpClient
} from '@microsoft/sp-http'

private _getListData(): Promise<ISPLists> {
  return this.context.spHttpClient.get(this.context.pageContext.web.absoluteUrl + '/_api/SP.UserProfiles.PeopleManager/GetMyProperties', SPHttpClient.configurations.v1)
    .then((response: Response) => {
      return response.json();
    });
}
3
  • Does this imply that SPFx's spHttpClient does not return a JSON structure by default?? Commented Jan 13, 2017 at 8:19
  • No, JSON is the default, as is ODataV4, etc. Those configurations are all captured in the V1 configuration. The full V1 configuration is * consoleLogging = true; * jsonRequest = true; * jsonResponse = true; * defaultSameOriginCredentials = true; * defaultODataVersion = ODataVersion.v4; * requestDigest = true The goal with the configuration is to be able to change defaults without breaking existing code, by combining those defaults into configurations. Commented Jan 13, 2017 at 18:04
  • my this.context.spHttpClient is undefined Commented Nov 5, 2019 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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