Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ErockF
Frequent Visitor

Sending PUT method call through Power Query (M)

Greetings!

 

I have three things I want to do in Power BI through a single M query. 

  1. Fetch ADSSO BOBJ token for the following rest calls. (Done)
  2. Refresh a Webi document. (Need Help)
  3. Pull data from aforementioned document. (Done)

I know that I can use Web.Contents to perform GET requests, and POST requests by adding the Contents option.

 

But, according to the SAP documentation, the http request to refresh a webi document has to be a PUT I confirmed that this works through Postman.

 

I found the Power Query M function, WebMethod.Put but have not found any mention of how in the heck to use it, or any of the other WebMethod functions. 

 

Does anyone have experience using these WebMethod functions? Or, has anyone been able to successfully update a SAP Webi document before pulling in the data through other means?

 

Help is appreciated!

 

Thanks!

 

-Eric

5 REPLIES 5
johnihab
Frequent Visitor

Has anyone found a solution ?

Anonymous
Not applicable

Hi,

 

I just found a solution to this problem using an external service called Integromat.

This tool allows you to integrate various applications easily.

 

I created the following scenario:

  1. Webhook listener - receive your Power BI GET request.
  2. HTTP  - take the webhook parameters and send them using the "PUT" method to your application.
  3. Webhook Response - take the HTTP PUT response and send it back to your Power BI.

That's it.

 

Hope I helped

 

ezrae_0-1605259671681.png

ezrae_1-1605260293308.png

 

ezrae_2-1605260337561.png

 

 

 

v-juanli-msft
Community Support
Community Support

Hi @v-juanli-msft,

 

Thank you for your response.

 

It looks like out of the three links you mentioned, the first two use Contents=Text.ToBinary() as a solution to turn the Web.Contents into a POST and the third looks like a powershell solution.

 

Maybe I am not reading the posts right, could you provide some more specifics?

 

Thanks!

 

Has anyone found a solution to this issue?

Tried WebAction.Request (which seems to be the only possible interface to do a PUT request) and all I get is errors pushed back (see below)...

I'm testing to just try to get webaction to work but it's crapping out on the request itself....

The lack of documentation and examples for the power query/M language is brutal and what you can do within power query is more of a mystery than anything. Someone from Microsoft with knowledge, please chime in...

 

NOTES:

1) Web.Contents works BUT only supports POST and GET request methods, need access to PUT and DELETE methods

2) Data repository is located behind an oData api 

3) Working from within power query advance query editor.

4) Tried OData.Feed as well but the reponse from the api does not have have response header set so that craps out as well AND don't know if it supports allrequest methods as well!

 

 

let
	Source = Text.FromBinary(
		WebAction.Request("GET","https://myurl.com/db/table", 
			[
			Headers=[Accept="application/json",ContentType="application/json",user="***************",password="***********************"]
			]
		)
	),
    FixJsonRecords="[" & Text.Replace(Text.Replace(Source,"}{","},{"),"{""queryType"":""select""},","") & "]",
	fixResult=Table.FromRecords(Json.Document(FixJsonRecords))
in
    fixResult

 

 

***** Error *****

Error Message:
Object reference not set to an instance of an object.

Stack Trace:
at Microsoft.Mashup.Host.Document.Evaluation.EvaluationResult.CreateExceptionResult(Exception exception)
at Microsoft.Mashup.Host.Document.Analysis.PackageDocumentAnalysisInfo.PackagePartitionAnalysisInfo.FormulaMetadataRecorder.RecordException(FormulaAnalyzerScope scope, Exception exception, DateTime staleSince, Boolean sampled)
at Microsoft.Mashup.Host.Document.Analysis.PackageDocumentAnalysisInfo.PackagePartitionAnalysisInfo.SetPreviewValue(EvaluationResult2`1 result, Func`1 getStaleSince, Func`1 getSampled)
at Microsoft.Mashup.Host.Document.Analysis.CachingDocumentAnalysisInfo.CachingPartitionAnalysisInfo.SetPreviewValue(EvaluationResult2`1 result, Func`1 getStaleSince, Func`1 getSampled)
at Microsoft.Mashup.DocumentHost.DocumentAnalyzer.Analyze(IPartitionAnalysisInfo partitionInfo, AccessRecorder recorder, EvaluationResult2`1 result, Action`1 callback)
at Microsoft.Mashup.DocumentHost.DocumentAnalyzer.<>c__DisplayClass10.<BeginAnalyzeDocumentPartition>b__d(EvaluationResult2`1 result)
at Microsoft.Mashup.Evaluator.Interface.EvaluationResultExtensions.InvokeThenOnDispose(Action`1 callback, EvaluationResult2`1 result, Action action)
at Microsoft.Mashup.Evaluator.Interface.EvaluationResultExtensions.InvokeThenOnDispose[T](Action`1 callback, EvaluationResult2`1 result, Action action)
at Microsoft.Mashup.Evaluator.LimitedDocumentEvaluatorFactory.Evaluation`1.Complete(EvaluationResult2`1 result)
at Microsoft.Mashup.Evaluator.Interface.EvaluationResultExtensions.InvokeThenOnDispose(Action`1 callback, EvaluationResult2`1 result, Action action)
at Microsoft.Mashup.Evaluator.Interface.EvaluationResultExtensions.InvokeThenOnDispose[T](Action`1 callback, EvaluationResult2`1 result, Action action)
at Microsoft.Mashup.Evaluator.LimitedDocumentEvaluatorFactory.Evaluation`1.Complete(EvaluationResult2`1 result)
at Microsoft.Mashup.Evaluator.Interface.EvaluationResultExtensions.InvokeThenOnDispose(Action`1 callback, EvaluationResult2`1 result, Action action)
at Microsoft.Mashup.Evaluator.Interface.EvaluationResultExtensions.InvokeThenOnDispose[T](Action`1 callback, EvaluationResult2`1 result, Action action)
at Microsoft.Mashup.Evaluator.DocumentEvaluator.<>c__DisplayClass3`1.<BeginGetResult>b__0(EvaluationResult2`1 result)
at Microsoft.Mashup.Evaluator.Interface.EvaluationResultExtensions.InvokeThenOnDispose(Action`1 callback, EvaluationResult2`1 result, Action action)
at Microsoft.Mashup.Evaluator.Interface.EvaluationResultExtensions.InvokeThenOnDispose[T](Action`1 callback, EvaluationResult2`1 result, Action action)
at Microsoft.Mashup.Evaluator.LimitedDocumentEvaluatorFactory.Evaluation`1.Complete(EvaluationResult2`1 result)
at Microsoft.Mashup.Evaluator.RemoteDocumentEvaluator.RemoteEvaluation`1.TryComplete(EvaluationResult2`1 result)
at Microsoft.Mashup.Evaluator.RemoteDocumentEvaluator.PreviewValueSourceRemoteEvaluation.GetResult(Boolean enableFirewall)
at Microsoft.Mashup.Evaluator.RemoteDocumentEvaluator.RemoteEvaluation.Evaluate(Boolean enableFirewall)
at Microsoft.Mashup.Evaluator.RemoteDocumentEvaluator.EvaluationThread(Object state)
at Microsoft.Mashup.Evaluator.GlobalizedEvaluatorThreadPool.<>c__DisplayClass4.<Start>b__3(Object s)
at Microsoft.Mashup.Evaluator.EvaluatorThreadPool.EvaluatorThread(Object state)
at Microsoft.Mashup.Evaluator.SafeThread2.<>c__DisplayClass2.<CreateThreadStart>b__0(Object o)
at Microsoft.Mashup.Evaluator.SafeThread2.<>c__DisplayClass15.<CreateAction>b__14(Object o)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.