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 Automate / Join site hub - Bad Ga...
Power Automate
Unanswered

Join site hub - Bad Gateway 502

(0) ShareShare
ReportReport
Posted on by 265

I have created the following flow. Does anybody know why I get this "Bad Gateway 502" error? I have tried to remove the Sharepoint connection for the flow and log back in, but I still get the same error.

 

ThomasDK_0-1633431250627.png

 

Raw output:

{
    "statusCode"502,
    "headers": {
        "Pragma""no-cache",
        "x-ms-request-id""9e21f69f-604e-c000-762a-a2cebe7d5da2",
        "Strict-Transport-Security""max-age=31536000; includeSubDomains",
        "X-Content-Type-Options""nosniff",
        "X-Frame-Options""DENY",
        "Cache-Control""no-store, no-cache",
        "Set-Cookie""ARRAffinity=7fec6b3d494d502cd339a098a470860ddaf458b68c32b8ce8e190c362de93b94;Path=/;HttpOnly;Secure;Domain=sharepointonline-ne.azconn-ne.p.azurewebsites.net,ARRAffinitySameSite=7fec6b3d494d502cd339a098a470860ddaf458b68c32b8ce8e190c362de93b94;Path=/;HttpOnly;SameSite=None;Secure;Domain=sharepointonline-ne.azconn-ne.p.azurewebsites.net",
        "Timing-Allow-Origin""*",
        "x-ms-apihub-cached-response""true",
        "Date""Tue, 05 Oct 2021 10:08:27 GMT",
        "Content-Length""591",
        "Content-Type""application/json",
        "Expires""-1"
    },
    "body": {
        "error": {
            "code"502,
            "source""flow-apim-europe-001-westeurope-01.azure-apim.net",
            "clientRequestId""252902f8-e6b9-464f-a6f5-de0020b42229",
            "message""BadGateway",
            "innerError": {
                "status"502,
                "message""Hub site not found\r\nclientRequestId: 252902f8-e6b9-464f-a6f5-de0020b42229\r\nserviceRequestId: 9e21f69f-604e-c000-762a-a2cebe7d5da2",
                "source""https://domain.sharepoint.com/sites/nt32/_api/site/JoinHubSite",
                "errors": [
                    "-2147213254",
                    "Microsoft.SharePoint.SPException"
                ]
            }
        }
    }
}
Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,183 Most Valuable Professional on at

    Hi @ThomasDK,

     

    You are associating one site collection with another (hub) site collection. So, I would expect you to use the GUIDs of the site collections and not from the Root webs of both site collections.

     

    Can you change the Uri of the two Send an HTTP requests from _api/web to _api/site

     

    sitecollectionguid.png

  • ThomasDK Profile Picture
    265 on at

    Hi @Expiscornovus ,

     

    Changing from "_api/web" to "_api/site" seems to yield the same result.

     

    I'm not sure if I understand you correctly, but in my "Join hub site" step I use the site address because it expects me to. I once tried with the GUID, but it told me to use the site address.

     

    In the meantime I have created a new hub site based om a Communication site, as this is more simple because it is not based om a O365 group. I have made the delegated Oauth user and the user handling the connection in the steps SiteCollection Admin. Also, I have stated that these two users are the users who can approve Hub Site join requests. So, I should think that the permissions should be OK. But, I'm getting an error saying: "Attempted to perform an unauthorized operation.". I have seen this before and as I recollect I solved it by adding the connections to the created SP sites.

    ThomasDK_0-1633609066249.png

     

    I have looked into the BadGateway500 (%02) error and there are myriads of reasons why this can be occur. Eg. it can be a person field that has been changed to accept multiple persons. My guess is that I have some client side misconfiguration.. because I really don't think it is an Azure network/DNS problem of som sort.

     

    I hope you can help as I'm out of good ideas 🙂

  • Expiscornovus Profile Picture
    33,183 Most Valuable Professional on at

    Hi @ThomasDK,

     

    Apologies if I wasn't clear. I was not talking about the Request Site Address value, the site which we want to join to the hub.

     

    I was talking about the hub itself, and the Hub Site Id value. The error says it cannot find your hub.

     

    I can reproduce the Hub Site not found error when using that _api/web method for retrieving the Hub Site Id value.

     

    Below are a couple of screenshots to show you.

    Let's assume in this example that my Hub site has a GUID which is 9a356380-ce9a-4be5-aa85-ba239d9fec6a. 

     

    1. In my test the _api/web gives me a different GUID.

    hubsiteguidnotfound01.png

     

    2. That results in a HTTP 502 Bad Gateway Hub site not found error (as in your opening post).

     

    hubsiteguidnotfound02.png

     

    3. When I use the _api/site I get the correct GUID which I can set to the variable.

     

    hubsiteguidnotfound03.png

     

    Hopefully this helps a bit?

     

  • rjack Profile Picture
    188 on at

    Out of curiosity, you are not sending to anyone for approval to join the site, why dont you disable approve option and simple use join hub site action? this is not causing your 502 error but just saying. 

     

    have you tried hardcoding the hub site ID like below? if you have only one hub site and you dont need to dynamically fetch the site ID, i suggest hardcode it unless there's some other issue. 

     

    rjack_1-1633629120226.png

     

     

  • ThomasDK Profile Picture
    265 on at

    Hi @Expiscornovus,

     

    Thank you very much for the clarification. It is quite strange that "web" fails and "Site" works, as the output looks similar. I will keep the Hub GUID in a variable and use "Site" 🙂

  • Expiscornovus Profile Picture
    33,183 Most Valuable Professional on at

    Hi @ThomasDK,

     

    Great to hear it works.

     

    Site, site collection, web, root web. Don't get me started on the subject of the different objects in SharePoint. Even after explaining the SharePoint architecture to customers in the last 15 years I still understand it is kind of confusing 😁

  • ThomasDK Profile Picture
    265 on at

    Hi @rjack 

     

    This is the third time I start a reply to you in this thread. The last two times I thought I'd try something out and then it logs out and I loose my reply. Third time must be the charm 🙂

     

    I really don't want the approval flow, as it is not necessary in my flow. I tried to build my flow without it previously but did not succeed. I have now tried again. This following shows the setup and the result. Please help me find out what I'm not doing right. I get this error:

    ThomasDK_1-1634193239215.png

     

    The Hub site, where the approval is not required:

    A communication site with these settings:

    ThomasDK_0-1634193216441.png

    The flow step:

    ThomasDK_2-1634193297504.png

     

    Now, the error suggests that the problem is permissions. I have these permisssions on the Hub Site:

    Connection user = the user logged in to Sharepoint in the flow step.

     

    ThomasDK_3-1634193346701.png

     

    The only thing I can think of is the Sharepoint site, that is created together with my team, which I want to join to the Hub Site, could be the problem. The user that created the Team, is the same user 'manageing' the connection to Sharepoint and I guess that this user must have rights on the Sharepoint site. BUT.. when I look at the Sharepoint site, which I want to join, I don't see that this user has any rights when I look at advanced rights management. Nothing in the groups or otherwise.

     

  • rjack Profile Picture
    188 on at

    Hi @ThomasDK 

    Sorry i couldn't understand the language in one of the screenshot but i assume it is not hub site approval work flow setting. in the below article, search for 'Manage site association approval flows' title and follow the article to turn off the work flow process. i believe this is why you need an approval process.

     

    Set up your SharePoint hub site (microsoft.com)

  • ThomasDK Profile Picture
    265 on at

    I can see how this part of my explanation can be confusing, although I try to be explicit 🙂 What I mean is that I turn off the approval requirement:

    ThomasDK_0-1634535588819.png

    BR,

    Thomas

  • rjack Profile Picture
    188 on at

    ha! now i understand. lol! when i saw the green arrow in the screenshot, I was expecting an annotation on the image. my bad! 

     

    since you have turned off the approval for the site, you need to remove the actions that are used for approval. this is based on assumption from your Wednesday message which contains at least one of the action that are in the below image.

     

    rjack_0-1634574365626.png

     

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 Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 523 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard