web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How do you use the Off...
Power Apps
Suggested Answer

How do you use the Office365.Groups.HttpRequest(URI, Method, file)

(0) ShareShare
ReportReport
Posted on by 26

I would like to query Graph from PowerApps by providing a Group DisplayName or mailNickName.

 

Currently this works in Graph Explorer - https://graph.microsoft.com/v1.0/groups?$filter=mailNickname eq '<nickname>' but I can't find any documentation to use the Office365.Groups.HttpRequest("https://graph.microsoft.com/v1.0/groups?$filter=mailNickname eq '<nickname>'", "GET", file) to make it work.

 

What am I supposed to use for 'file'?

 

Where do I find information about how to structure the formula in PowerApps? I am trying to use instructions from this docs.microsoft.com page: Office 365 Groups - Connectors | Microsoft Docs

Categories:
I have the same question (0)
  • v-xiaochen-msft Profile Picture
    on at

    Hi @Justin-GOV ,

     

    Unfortunately, this parameter (file) has not been introduced in the documentation.

    I suggest you use Office365.Groups.HttpRequest action in flow.

     

    Best Regards,

    Wearsky

  • Justin-GOV Profile Picture
    26 on at

    Thank you for your reply @v-xiaochen-msft. Do you have an example where Office365.Groups.HttpRequest works? It seems the 'file' parameter is required. I can't use the action because it's expecting 'file.'

     

    Specifically, I get the error: 'Invalid number of arguments: received 2, expected 3-4.'

     

    Thanks again,

    Justin

  • v-xiaochen-msft Profile Picture
    on at

    Hi @Justin-GOV ,

     

    No. I don’t know what to fill in the parameter.  😞

     

    Best Regards,

    Wearsky

  • PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on at

    Hey,

    I also took a look at this connector. The "file" property seems to be the request body. But unfortunately, there is no out of the box way to work with the result. Looking at the monitor results it clearly shows that the request is correct and also that there is a propper result. I have used: 

     

    Set(varMe,Office365Groups.HttpRequest("https://graph.microsoft.com/v1.0/me","GET","",{ContentType:"application/json"}))

     

    And varMe is set to "true".

     

    Look at this excellent video to see how you could get a propper result which you could use in PowerApps.

    Call MS Graph API Directly From Power Apps - YouTube

     

    regards,

    Lutz

     

  • santy2 Profile Picture
    15 on at

    Thanks to @PowerRanger  and the excellent video he provided , 

     

    I was able to create a working example

     

    https://powerusers.microsoft.com/t5/Building-Power-Apps/Office365Groups-HttpRequest-Formula/m-p/1929136#M484573

     

    and also get more properties from the Get User Profile V2 for PowerApps - when using $select

     

    https://github.com/MicrosoftDocs/BusinessApplicationPlatform-Connectors-public/issues/23#issuecomment-1353886508

     

     

    Regards,

     

  • dotter Profile Picture
    8 on at

    So PowerApps has had a couple updates in the past few months to help enable this functionality. You can now send any HTTP request through PowerApps natively (without having to export the msapp file and tinker with it in VS Code) - just by making sure that the "ParseJSON and Untyped Objects" preview feature is turned on. It seems to be turned on by default in all new apps (at least in my version of PowerApps), so that's helpful - but if you have an older app and don't have it turned on - turn it on, then save and reload your app editor screen.

     

    So, what that allows you to do is actually parse the response from the action (which after you turn it on, is returned as an "untyped object" rather than boolean true/false) and you can type-cast properties from your response individually. Here's a great example in MS Documentation: Working with untyped and dynamic objects - Power Apps | Microsoft Learn - they even use the HttpRequest() action there. Problem is that they use a "GET" request that doesn't require a Body input so there's no example on that.

     

    If you want an HTTP request that includes a body input - that does need to be of a "file" type. You can't just type in your request in JSON formatting, you have to have it set up as a file. You can do this by adding an Image control, putting "data&colon;text/plain;base64," as your Image property - and then convert your JSON payload from string to Base64 using the method described in this blog post: Encode/Decode Base64 in Power Apps without Flow - MoreBeerMorePower (hatenablog.com) and concatenate all that together.

     

    When you go to call your HTTP request, it'll look like this:

    Office365Groups.HttpRequest("https://graph.microsoft.com/v1.0/groups/{groupId}","PATCH",Image1.Image)

    Where your Image1.Image is just your data-URI encoded Base64 body for your request.

     

    Is this way more complicated than it needs to be? Yes, absolutely - but you don't need a Flow to call an HTTP request and get a response anymore.

  • tonyxrc Profile Picture
    15 on at

    Hello, I have turned on ParseJSON and Untyped Objects and reload the app. But the file type is still boolean for offficr365group. Any reason why?

    Thanks 

  • dventura Profile Picture
    52 on at

    Remove the connector save and exit. Open the app add the connector back, save and exit. Then open it once more and it should now display Untyped Objects instead of boolean.

  • ohgee Profile Picture
    13 on at

    Hey dotter... I'm trying your method out to create a new folder in SharePoint.  The Image1.Image value is data&colon;text/plain;base64,SGFwcHkgSG9saWRheXM= which is the text you said to lead with, and the result of the "encode plain text to base64" directly from the link you provided ("Happy Holidays" in this case).  I am still getting the error "Empty Payload. JSON content expected."

     

    Any thoughts as to what I could be doing wrong?  Thank you!

    Office365Groups.HttpRequest(
    "https://graph.microsoft.com/v1.0/sites/<site guid>/drive/items/root/children",
    "POST",
    Image1.Image);

  • johnxt Profile Picture
    on at

    I've been fighting this for nearly 2 solid days, many thanks to dotter for putting me on the right track. So here's how I did it, forget the image box you don't need that. Just generate yourself the proper string and put it into a variable, then send that to the httprequest. The reason why dotter's example code didnt work for you as typed is because of a slight error it should be "data:" not "data&colon;" (some kind of html decoding issue somewhere along the line I guess)

     

    For testing, I made 2 buttons to quickly generate the required string then post it into a list on our sharepoint site. Button1.OnSelect:

    Set(myJSONString, 
     "{""fields"":{""Title"":""John Smith""}}"
    );
    Set(myBinaryString,With({
     InputText:myJSONString,
     AsciiTable:AddColumns(Sequence(2^8,1),"char",Char(Value)),
     B64ToBin:
     Table(
     {b64:"A",bin:"000000"},
     {b64:"B",bin:"000001"},
     {b64:"C",bin:"000010"},
     {b64:"D",bin:"000011"},
     {b64:"E",bin:"000100"},
     {b64:"F",bin:"000101"},
     {b64:"G",bin:"000110"},
     {b64:"H",bin:"000111"},
     {b64:"I",bin:"001000"},
     {b64:"J",bin:"001001"},
     {b64:"K",bin:"001010"},
     {b64:"L",bin:"001011"},
     {b64:"M",bin:"001100"},
     {b64:"N",bin:"001101"},
     {b64:"O",bin:"001110"},
     {b64:"P",bin:"001111"},
     {b64:"Q",bin:"010000"},
     {b64:"R",bin:"010001"},
     {b64:"S",bin:"010010"},
     {b64:"T",bin:"010011"},
     {b64:"U",bin:"010100"},
     {b64:"V",bin:"010101"},
     {b64:"W",bin:"010110"},
     {b64:"X",bin:"010111"},
     {b64:"Y",bin:"011000"},
     {b64:"Z",bin:"011001"},
     {b64:"a",bin:"011010"},
     {b64:"b",bin:"011011"},
     {b64:"c",bin:"011100"},
     {b64:"d",bin:"011101"},
     {b64:"e",bin:"011110"},
     {b64:"f",bin:"011111"},
     {b64:"g",bin:"100000"},
     {b64:"h",bin:"100001"},
     {b64:"i",bin:"100010"},
     {b64:"j",bin:"100011"},
     {b64:"k",bin:"100100"},
     {b64:"l",bin:"100101"},
     {b64:"m",bin:"100110"},
     {b64:"n",bin:"100111"},
     {b64:"o",bin:"101000"},
     {b64:"p",bin:"101001"},
     {b64:"q",bin:"101010"},
     {b64:"r",bin:"101011"},
     {b64:"s",bin:"101100"},
     {b64:"t",bin:"101101"},
     {b64:"u",bin:"101110"},
     {b64:"v",bin:"101111"},
     {b64:"w",bin:"110000"},
     {b64:"x",bin:"110001"},
     {b64:"y",bin:"110010"},
     {b64:"z",bin:"110011"},
     {b64:"0",bin:"110100"},
     {b64:"1",bin:"110101"},
     {b64:"2",bin:"110110"},
     {b64:"3",bin:"110111"},
     {b64:"4",bin:"111000"},
     {b64:"5",bin:"111001"},
     {b64:"6",bin:"111010"},
     {b64:"7",bin:"111011"},
     {b64:"8",bin:"111100"},
     {b64:"9",bin:"111101"},
     {b64:"+",bin:"111110"},
     {b64:"/",bin:"111111"}
     )},
     With({
     BinRep:
     Concat(
     AddColumns(ForAll(Split(InputText,""), {Result: ThisRecord.Value}),"dec",LookUp(AsciiTable,char=Result).Value),//Convert text to Ascii character code (decimal)
     Concat(Sequence(8,8,-1),Text(If(And(Mod(dec,Power(2,Value))>=Power(2,Value-1),Mod(dec,Power(2,Value))<Power(2,Value)),1,0)))&"","")//Convert decimal to binary
     },
     With({b64string:Concat(
     Sequence(
     RoundUp(Len(BinRep)/6,0),0),
     LookUp(
     B64ToBin,
     bin=Mid(BinRep&Left("000000",6-Mod(Len(BinRep),6)),6*Value+1,6) //Left("000000"....) is padding right with zero
     ).b64&"", 
     ""
     )},
     b64string&Left("====",Mod(4-Mod(Len(b64string),4),4))//Convert binary to base64
     )
     )
    ));
    
    Set(myGeneratedBlob,"data&colon;application/json;base64," & myBinaryString)

    Button2.OnSelect:

    Office365Groups.HttpRequest("https://graph.microsoft.com/v1.0/sites/<sharepoint site id>/lists/<sharepoint list id>/items","POST",myGeneratedBlob)

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard