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 / SharePoint HTTP call f...
Power Automate
Unanswered

SharePoint HTTP call fails with '502 Bad Gateway'

(0) ShareShare
ReportReport
Posted on by 10

I'm building a flow to create a SP library but the response is 502 Bad Gateway. It seems to affect libraries created on this particular subsite as when creating on root or other subsites the error is not present. I suspect something to do with content types / policy issue but the error is not clear and I'm out of ideas.

 

Update: Forgot to mention; the library is still successfully created. However instead of a 200 I get the 502 and so the flow breaks at that point onward and is marked as Failed.

 

The Input

 

 

 

{
 "host": {
 "connectionReferenceName": "shared_sharepointonline",
 "operationId": "HttpRequest"
 },
 "parameters": {
 "dataset": "https://xxx.sharepoint.com/sites/project_xxx/XSS Documentation",
 "parameters/method": "POST",
 "parameters/uri": "_api/web/lists",
 "parameters/headers": {
 "Accept": "application/json;odata=verbose",
 "Content-Type": "application/json"
 },
 "parameters/body": "{\n \"AllowContentTypes\": false,\n \"BaseTemplate\": 101,\n \"ContentTypesEnabled\": false,\n \"Description\": \"This is a SharePoint library called \",\n \"Title\": \"test4\"\n}"
 },
 "retryPolicy": {
 "type": "None"
 }
}

 

 

 

 

Output

 

 

 

{
 "statusCode": 502,
 "headers": {
 "Cache-Control": "no-store, no-cache",
 "Pragma": "no-cache",
 "Set-Cookie": "ARRAffinity=xxx;Path=/;HttpOnly;Secure;Domain=sharepointonline-ae.azconn-ae-001.p.azurewebsites.net,ARRAffinitySameSite=c3e56c5cc8f2059e9ca5b31ea6306f0b4d439389925f19007ee442dc2004e749;Path=/;HttpOnly;SameSite=None;Secure;Domain=sharepointonline-ae.azconn-ae-001.p.azurewebsites.net",
 "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
 "x-ms-datasourceerror": "True",
 "x-ms-request-id": "c8d726a1-00a4-3000-3bed-2726117c4bda",
 "X-Content-Type-Options": "nosniff",
 "X-Frame-Options": "DENY",
 "Timing-Allow-Origin": "*",
 "x-ms-apihub-cached-response": "false",
 "x-ms-apihub-obo": "false",
 "Date": "Thu, 09 May 2024 03:05:00 GMT",
 "Content-Length": "621",
 "Content-Type": "application/json",
 "Expires": "-1"
 },
 "body": {
 "error": {
 "code": 502,
 "source": "australia-001.azure-apim.net",
 "clientRequestId": "28dc4028-1252-4197-b23e-ae3ef143724d",
 "message": "BadGateway",
 "innerError": {
 "status": 502,
 "message": "Exception from HRESULT: 0x8107140F\r\nclientRequestId: 28dc4028-1252-4197-b23e-ae3ef143724d\r\nserviceRequestId: c8d726a1-00a4-3000-3bed-2726117c4bda",
 "source": "https://xxx.sharepoint.com/sites/project_xxx/XSS%20Documentation/_api/web/lists",
 "errors": [
 "-2130242545",
 "Microsoft.SharePoint.SPException"
 ]
 }
 }
 }
}

 

 

 

Categories:
I have the same question (3)
  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @ncaropt,


    Just to double check. There is a space in the name of the address of the subsite, can you double check you used the correct site address? 

     

    Did you also try running a GET request on the subsite, does that work?

     

  • ncaropt Profile Picture
    10 on at

    Hi Expiscornovus

    Yes, the sub-site name has a space in it.

    Performing a GET request works fine, it is the POST to create a library that seems to fail.

     

    GET Input

     

    {
     "host": {
     "connectionReferenceName": "shared_sharepointonline",
     "operationId": "HttpRequest"
     },
     "parameters": {
     "dataset": "https://xxx.sharepoint.com/sites/project_xxxdocuments/XXX Documentation",
     "parameters/method": "GET",
     "parameters/uri": "_api/web/lists",
     "parameters/headers": {
     "Accept": "application/json;odata=verbose",
     "Content-Type": "application/json"
     }
     },
     "retryPolicy": {
     "type": "None"
     }
    }

     

    GET OUTPUT

     

     

    	
    statusCode	200
    headers	
    Cache-Control	"no-store, max-age=0, private"
    Transfer-Encoding	"chunked"
    Vary	"Origin,Accept-Encoding"
    Set-Cookie	"ARRAffinity=c3e56c5cc8f2…001.p.azurewebsites.net"
    Strict-Transport-Security	"max-age=31536000"
    X-NetworkStatistics	"0,262656,0,0,56,0,23420,14"
    X-SharePointHealthScore	"1"
    X-SP-SERVERSTATE	"ReadOnly=0"
    DATASERVICEVERSION	"3.0"
    SPClientServiceRequestDuration	"1789"
    SPRequestDuration	"1790"
    X-DataBoundary	"NONE"
    X-1DSCollectorUrl	"https://mobile.events.da…ft.com/OneCollector/1.0/"
    X-AriaCollectorURL	"https://browser.pipe.ari…osoft.com/Collector/3.0/"
    SPRequestGuid	"fabd28a1-409a-3000-395c-4baf0f6b7661"
    Request-Id	"fabd28a1-409a-3000-395c-4baf0f6b7661"
    MS-CV	"oSi9+ppAADA5XEuvD2t2YQ.0"
    X-Frame-Options	"SAMEORIGIN,DENY"
    Content-Security-Policy	"frame-ancestors 'self' t…r.sharepointonline.com;"
    MicrosoftSharePointTeamServices	"16.0.0.24901"
    X-Content-Type-Options	"nosniff,nosniff"
    X-MS-InvokeApp	"1; RequireReadOnly"
    P3P	'CP="ALL IND DSP COR ADM …AV ONL PHY PRE PUR UNI"'
    X-AspNet-Version	"4.0.30319"
    X-Powered-By	"ASP.NET"
    x-ms-request-id	"fabd28a1-409a-3000-395c-4baf0f6b7661"
    Timing-Allow-Origin	"*"
    x-ms-apihub-cached-response	"true"
    x-ms-apihub-obo	"false"
    Date	"Wed, 15 May 2024 00:41:54 GMT"
    Content-Type	"application/json; odata=verbose; charset=utf-8"
    Content-Length	"2862647"
    Expires	"Tue, 30 Apr 2024 00:41:53 GMT"
    Last-Modified	"Wed, 15 May 2024 00:41:53 GMT"
    body	
    d	
    results	
    0	{…}
    1	{…}
    2	{…}
    3	{…}
    4	{…}
    5	{…}
    6	{…}
    7	{…}
    
  • Alex256 Profile Picture
    84 on at

    So, I have made some test with your scenario. Have you tried to change the name of the title and sometimes the flow going to use the old body of the previous flow to send the request. This is the result I tried:

    Alex256_0-1715746148349.png

    Alex256_3-1715746308930.png

    Alex256_4-1715746333940.png

     

     

     

  • ncaropt Profile Picture
    10 on at

    Hi Alex, I'm not sure what you mean exactly, which title should I try to change?

  • Alex256 Profile Picture
    84 on at

    So, title should be in the body of the action http request.

    Alex256_0-1715747788947.png

     

  • ncaropt Profile Picture
    10 on at

    I have tried various titles but still the same issue. Could it be because the sub-site has a space in the name?

  • Alex256 Profile Picture
    84 on at
     "parameters": {
     "dataset": "https://xxx.sharepoint.com/sites/project_xxx/XSS Documentation",

    Can you change this to :

     "parameters": {
     "dataset": "https://xxx.sharepoint.com/sites/project_xxx/XSS%20Documentation",
  • ncaropt Profile Picture
    10 on at

    Hi Alex

    I have tried this but still fails with BadGateway error. Note that the library is still successfully created, it is just getting the 502 response. This impacts the flow as it enters an error state and does not continue.

     

    Input

    {
     "host": {
     "connectionReferenceName": "shared_sharepointonline",
     "operationId": "HttpRequest"
     },
     "parameters": {
     "dataset": "https://xxx.sharepoint.com/sites/project_xxx/XXX%20Documentation",
     "parameters/method": "POST",
     "parameters/uri": "_api/web/lists",
     "parameters/headers": {
     "Accept": "application/json;odata=verbose",
     "Content-Type": "application/json"
     },
     "parameters/body": "{\n \"AllowContentTypes\": false,\n \"BaseTemplate\": 101,\n \"ContentTypesEnabled\": false,\n \"Description\": \"This is a SharePoint library called \",\n \"Title\": \"testt21\"\n}"
     },
     "retryPolicy": {
     "type": "None"
     }
    }

     

    Output

    {
     "statusCode": 502,
     "headers": {
     "Cache-Control": "no-store, no-cache",
     "Pragma": "no-cache",
     "Set-Cookie": "ARRAffinity=c3e56c5cc8f2059e9ca5b31ea6306f0b4d439389925f19007ee442dc2004e749;Path=/;HttpOnly;Secure;Domain=sharepointonline-ae.azconn-ae-001.p.azurewebsites.net,ARRAffinitySameSite=c3e56c5cc8f2059e9ca5b31ea6306f0b4d439389925f19007ee442dc2004e749;Path=/;HttpOnly;SameSite=None;Secure;Domain=sharepointonline-ae.azconn-ae-001.p.azurewebsites.net",
     "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
     "x-ms-datasourceerror": "True",
     "x-ms-request-id": "0fd228a1-3041-3000-47a9-4113c5ad52c4",
     "X-Content-Type-Options": "nosniff",
     "X-Frame-Options": "DENY",
     "Timing-Allow-Origin": "*",
     "x-ms-apihub-cached-response": "false",
     "x-ms-apihub-obo": "false",
     "Date": "Wed, 15 May 2024 06:32:49 GMT",
     "Content-Length": "621",
     "Content-Type": "application/json",
     "Expires": "-1"
     },
     "body": {
     "error": {
     "code": 502,
     "source": "australia-001.azure-apim.net",
     "clientRequestId": "4eafa5c2-c984-4d17-88d6-cbf188622379",
     "message": "BadGateway",
     "innerError": {
     "status": 502,
     "message": "Exception from HRESULT: 0x8107140F\r\nclientRequestId: 4eafa5c2-c984-4d17-88d6-cbf188622379\r\nserviceRequestId: 0fd228a1-3041-3000-47a9-4113c5ad52c4",
     "source": "https://xxx.sharepoint.com/sites/project_xxx/XXX%20Documentation/_api/web/lists",
     "errors": [
     "-2130242545",
     "Microsoft.SharePoint.SPException"
     ]
     }
     }
     }
    }

     

    Library still created

    ncaropt_0-1715755026650.png

     

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

    Hi @ncaropt,

     

    Can you double check your site address for us in your browser address bar? Just want to make sure the site doesn't have a different url than the site title. This could happen if the site has been renamed in the past.

     

    navigatetosite.png 

    Can you also try the same request with the full metadata?

     

    Try the below and see if that makes a difference?

     

    Headers

     

    {
     "Accept": "application/json;odata=verbose",
     "Content-Type": "application/json;odata=verbose"
    }

     

     

    Body

     

    { 
    "__metadata": { "type": "SP.List" }, 
    "AllowContentTypes": false, 
    "BaseTemplate": 101,
    "ContentTypesEnabled": false, 
    "Description": "This is a SharePoint library called", 
    "Title": "TestFromPowerAutomate"
     }

     

     

    includemetadata_list.png

     

    I also have a blog with a similar sample, if that helps?

    https://www.expiscornovus.com/2024/04/02/create-library/

     

     

  • ncaropt Profile Picture
    10 on at

    Hi @Expiscornovus , tried your suggestion but same results. The URL I am using in the flow is correct, however the site title looks like it was renamed in the past as it does not match the URL. Both selecting the subsite and using a urlencoded custom value fails with the 502 bad gateway.

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 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard