How to resolve HTTPS POST failure, BAD Gateway 502, Azure Logic App SharePoint Online

Steve Wedge 31 Reputation points
2022-07-19T09:45:04+00:00

I'm working on a client project and over the past couple of days I have created a couple of Azure Logic Apps which are designed to take content from external feeds, Twitter & RSS, and post a News Link into a specified SharePoint Online site. After a little bit of debugging to get the structure of the output correct, including dealing with Tweets which have no Media URLs in them, I had both of these Logic Apps working. They had both completed successfully, posting a New Link (creating a new page for a news item on the respective sites).

I've come back to verify what has happened with any new posts on these feeds and found that both of them have failed with a 502 Bad Gateway error, here's the output from one of the failed executions of the trigger. For what its worth this is looking for new posts from the Office 365 IT Pros site and creating a link on the internal site, by posting a new link (we want to have some automated content curation, bringing together useful external articles into a single central location).

"body": {
"error": {
"code": 502,
"source": "logic-apis-eastus.azure-apim.net",
"clientRequestId": "93066cfc-05c9-4600-868e-8439a54e1c51",
"message": "BadGateway",
"innerError": {
"status": 502,
"message": "{\"odata.error\":{\"code\":\"-2130575336, Microsoft.SharePoint.SPException\",\"message\":{\"lang\":\"en-US\",\"value\":\"Invalid text value.\n\nA text field contains invalid data. Please check the value and try again.\"}}}\r\nclientRequestId: 93066cfc-05c9-4600-868e-8439a54e1c51\r\nserviceRequestId: e17d52a0-40e7-2000-297d-6a42e765e3e7",
"source": "https://mycompany.sharepoint.com/sites/ITInfrastructure-CollaborationMIddleware/_api/sitepages/pages/reposts",
"errors": []
}
}
}

As you can see the error makes reference to an invalid text value, but I can't determine where the problem could be. This is the input

{
"method": "post",
"path": "/datasets/https%253A%252F%252Fmycompany.sharepoint.com%252Fsites%252FITInfrastructure-CollaborationMIddleware/httprequest",
"host": {
"connection": {
"name": "/subscriptions/634e0965-c22c-4e55-ba34-7d320d396e24/resourceGroups/eastus-auto-rg/providers/Microsoft.Web/connections/sharepointonline-2"
}
},
"body": {
"body": "{\"BannerImageUrl\":\"https://i0.wp.com/office365itpros.com/wp-content/uploads/2022/06/O365Cover_800-1.jpg?w=800&ssl=1\",\"Description\":\"Microsoft Graph Support for SharePoint Online Tenant Settings\",\"IsBannerImageUrlExternal\":true,\"OriginalSourceUrl\":\"https://office365itpros.com/2022/07/19/microsoft-graph-api-tenantadmin/?utm_source=rss&utm_medium=rss&utm_campaign=microsoft-graph-api-tenantadmin\",\"ShouldSaveAsDraft\":false,\"Title\":\"Office365 IT Pros - The new tenant admin Microsoft Graph API allows access to read and update SharePoint Online tenant settings. Although the API offers limited capabilities for now, it marks the start of Graph support for tenant settings that are currently managed through admin portals or PowerShell. It's a welcome development.\",\"__metadata\":{\"type\":\"SP.Publishing.RepostPage\"}}",
"headers": {
"accept": "application/json",
"content-type": "application/json;odata=verbose;charset=utf-8"
},
"method": "POST",
"uri": "_api/sitepages/pages/reposts"
}
}

I even tried running the Logic App by resubmitting a trigger which had previously been successfully processed and it also now fails. I found this article https://powerusers.microsoft.com/t5/Using-Connectors/Send-an-HTTP-Request-to-SharePoint-fails-with-502-on-recurrence/td-p/131278, because Power Automate is essentially the same, which suggested that putting in a step which connects to the site before attempting the POST step would work, but this has not resolved the issue.

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,554 questions
Microsoft 365 and Office | SharePoint | For business | Windows
{count} votes

Accepted answer
  1. Bruno Lucas 4,436 Reputation points MVP
    2022-07-19T12:33:44.92+00:00

    Hi @Steve Wedge
    ,
    I'll try to find some time to replicate but on the meantime, look like that api save to those fields:

    222306-image.png

    Not sure if there is info out there on those fields size limit. Maybe you can try to manually add some shorter data to see if it works

    I also notice most examples add the main SharePoint site here. You use a subsite. But you mentioned it was working , right?

    222331-image.png

    The input for title looks suspicious. more than 255 chars. It looks to me that API for not be documented out there for this type of use may be depending on the SharePoint ui to control the input size. Can you try the same input with a shorter value for title?
    222220-image.png


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.