Posts

Showing posts from May, 2020

Sharepoint Online SPFx Search Rest Api 403

Image
In case you develop an SPFx and you try to use RestApi for Search (or maybe also with the SP Rest) and you get 403, this in because your Webpart is running in his own scope, under an IFRAME. The solution is to dynamically take your Absolute Url      let   filesQuery  =  this . context . pageContext . web . absoluteUrl ; Every SPFx Webpart has his own SPPageContextInfo. P.S. In case you choose to user SPHttpClient, you need 2 things to get over your 500 error: 1. use Default configuration (that should be v3 or v4) 2. change Accept header odata part to verbose      this . context . spHttpClient . get ( filesQuery ,  new   SPHttpClientConfiguration ({}),       {  headers :  {  Accept :   "application/json;odata=verbose;charset=utf-8"  } })         . then (( response :  SPHttpClientResponse )...