Asit
Asit

Reputation: 13

Power Automate Send an HTTP request to SharePoint returns BadGateway error when creating a Lookup field

I'm trying to use Power Automate to create a Lookup field in a SharePoint document library using the "Send an HTTP request to SharePoint" action. However, I’m encountering the following error:

Action 'Send_an_HTTP_request_to_SharePoint' failed: BadGateway

Here’s the API request I'm using to add the Lookup field:

{
  "Title": "Project Lookup",
  "FieldTypeKind": 7,
  "LookupList": "<List GUID of Reference List>",
  "LookupField": "Title",
  "__metadata": {
    "type": "SP.FieldLookup"
  }
}

Upvotes: 1

Views: 612

Answers (1)

beelow
beelow

Reputation: 111

The body of your Send an HTTP request to SharePoint action is just a little bit off. Here is the JSON body package I used to successfully create a lookup column in a SharePoint document library using Power Automate:

{
  'parameters': {
    '__metadata': {
      'type': 'SP.FieldCreationInformation'
    },
    'FieldTypeKind': 7,
    'Title': '<your column title>',
    'LookupListId': '<your lookup list ID>',
    'LookupFieldName': '<your lookup column name>'
  }
}

You didn't mention what endpoint you were using, but for this example I used _api/web/lists/getbytitle('<your document library title')/fields/addfield

Also, be sure your action's method is set to POST and you have the following headers:

accept: application/json;odata=verbose
content-type: application/json;odata=verbose

Here is a good resource for programmatically creating/getting columns in SharePoint lists using Power Automate.

Please let me know if this works!

Upvotes: 1

Related Questions