cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Justin-GOV
Frequent Visitor

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

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

31 REPLIES 31

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)

 

Ha. Just look at that. Its also messed up my button1 code the same way it did with dotters, and inside a code block no less. what a great job Microsoft!

So the last line should be this, but without spaces:

 

Set(myGeneratedBlob,"data : application/json;base64," & myBinaryString)

 

 

I am struggling with this I am using this to get the data i want 

Set(UserAzureAD,
Office365Groups.HttpRequest(
"

https://graph.microsoft.com/v1.0/users?$filter=userPrincipalName eq 'companyemail@company.com'&$select=id,displayName,userPrincipalName,onPremisesSamAccountName,jobTitle,officeLocation

",
"GET",
""
));

 

I can not use any of the data that comes back as it is an untypedobject

I can not see how to get in to a collection or table so i can use the data I mainly need the onpremsisisamaccountname as this seems to be the only way to get it.

Hello there, I'm by no means an expert at this stuff as until yesterday I hadn't even touched graph before lol

But I did find this page on my travels trying to understand the httprequest POST function, hopefully it can be of some help:
Untyped object data type - Power Platform | Microsoft Learn

Also this one:
powerapps-docs/powerapps-docs/maker/canvas-apps/untyped-and-dynamic-objects.md at main · MicrosoftDo...

 

Good luck!

Hi @johnxt 

 

thank you fir the response, yes i have seen this page and tried to use the part about arrays but it keeps giving me an error it expect array or table but actual is object

 

Thanks

 

When trying to convert to a table using

ForAll( Table(UserAzureAD), { FirstField: Value(ThisRecord.Value.id), SecondField: Text(ThisRecord.Value.displayName) } )

 

i get below error

MRBCODC_0-1695903347581.png

 

Ok, so I've been hammering away at it. And the solution is so simple, and yet such a pain 😄

Text(First(UserAzureAD.value).onPremisesSamAccountName)

so what it is, if you were running a query which returns a single result e.g:

Set(varResponse, Office365Groups.HttpRequest("https://graph.microsoft.com/v1.0/me","GET",""));

You could just use Text(varResponse.displayName) and be happy.

 

As you're running a query it returns an array of results (called 'value'), which you need to handle. Since in this case you're only returning 1 result you can just use First() to get it, if you wanted to return more you would handle it in your App the usual way ForAll() or whatever

I just come to the same conclusion like you say so simple but a huge annoyance!

 

my next issue is I am trying to send a variable in the api url but it is not changing the text in the request url it is only sending the name of the variable

Yes this was driving me insane as it was working with ME endpoint but the user wasn't working 
ForAll was not working for me either as I was going to run a generic query on for all users and store in a collection and do lookup to get the data i wanted but it don't seem like that is possible

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages