Posts

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 letfilesQuery = 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, newSPHttpClientConfiguration({}),       { headers: { Accept:"application/json;odata=verbose;charset=utf-8" } })         .then((response: SPHttpClientResponse) => {   response.json().then((responseJSON: any) => {   console.log(responseJSON);  //your code ...         });         }); 

Windows 10 Microphone not working

Start -> Settings -> Sound
under "Input" find "Manage sound devices" link
under "Input devices", click the devices and enable them

How to get RSS feed to Sharepoint List with Flow Automation

Image
3 simple steps - Recurrence,  RSS, Apply to each with some Composes

1 - Recurrence
Just state the recurrence of querying the feed


2 - Use the RSS connector, which actually just get the JSON array of the items :)
(at least in my case)


3 - Apply to each with some Composes

What can't be seen in the image is the formula, for each composite the formula is the same appart from the json field value, here "publishDate", place that in the "Expression" side of the "add dynamic content" and click "OK"

items('Apply to each')?['publishDate']
which apparently can be also be done with

item()?['User ID 1']

And create the SP item



P.S.
In order have distinct value items I set the SP list Title columns to force distinct values, it then shows an error for each attempt to create duplicate value















Web Api Create method with multiple parameters

Also, how to overload a method, say GET or PUT?

Well, lets start that with simple settings, you can't. Too many resources with partial examples makes you sometimes believe that it should be that simple (and maybe it should?), while its not.

It's also not that complicated...


Part 1 - understanding default design

When you create a new Web Api project (in vs 2017 Web Application -> empty, mark web api) you get basically nothing but the "WebApiConfig.cs" withing the "interesting" line is
routeTemplate: "api/{controller}/{id}",

And that means that whatever controller you create by default can only have it's 1st parameter, as in the url part, as "id". You cant create a method sending something like "string name".

Next step will be creating a controller class (with the (v2.1) in the end) and you will always get the suggestion of "ValuesController1". You cannot have the end of the controller name other than "Control…

How to access ngFor variable from child component or directive

the answer is ViewContainerRef

when you inject it into your constructor it has so much data in it. the ngFor data is in
this.vc['_view']['context']['$implicit']
directive full example

@Directive({
    selector:'td'
}) exportclassAddInvAmountBtnDirectiveimplementsAfterViewInit {
  el:HTMLElement constructor(ref:ElementRef, privatevc: ViewContainerRef) { this.el = ref.nativeElement   }

  @HostListener('click', ['$event']) tdClick(ev: Event){ console.log('vc._view.context.$implicit',
         this.vc['_view']['context']['$implicit']); ev.stopPropagation()   }
}

C# Asp.Net Mvc Impesonate in inner Ajax

Image
Scenario - an MVC app, while in the C# we are calling a REST api.

To make the job easier we are using RestSharp

The API is an inner api, using windows authentication

my steps:
1. using NtlmAuthenticator




2. using default credentials



3. web config - added all the following















4. IIS -> your site -> Authentication -> changed to the following











The great angular dynamic (components) edit page

Image
This one is a long story...

My comps goes like this, I GET from API a list of config rows, each of those has a list of config fields, each of those dynamically renders to an appropriate component, 2 of them are inherited 1 from another.

The flow is:
1. CTOR and ngOnInit, subscribce to 2 observables, 2 http requests for data.
2. Both subscribces call a ready fn that triggers the *ngIf
3. Then there is an *ngFor for the rows and another *ngFor for the fields
4. Down there I have my #container's for placement of a dynamic component
5. In some cases, since the dynamic component is inherited, its calling ngOnInit twice (its parent's ngOnInit)

Lets see how can we overcome each of these problems...
For implementation, see in my specially crafted git.



Problem 1:  the containers prop (my QueryList) is undefined

@ViewChildren ('container', { read:ViewContainerRef }) containers: QueryList<ViewContainerRef>;
In Part 1 of my app, open the console and see for yourself, whe…