0

I'm trying to create a field in a document library using a SharePoint 2013 workflow and HTTP call.

Based on what I found here: https://gist.github.com/MartinBodocky/8056791, I'm trying to reproduce the call on a SharePoint Workflow.

I've created a Workflow variable with this dictionary: (name) / (type) / (value)

  • __metadata / type Dictionary / Variable: metadata

  • Title / type String / Activity

  • FieldTypeKing / type Integer / 6

  • Required / type Boolean / False

  • Choices / type Dictionary / Variable: dictionaryActivities

In detail, the metadata variable:

  • type / type String / SP.FieldChoice

Then I've created the dictionaryActivities variable like this:

  • results / type String / 'Activity 1', 'Activity 2', 'Activity 3'

Then I created the HTTP call (POST) to this URL:

https://contoso.sharepoint.com/revisioni/_api/Web/Lists/GetByTitle('[%Current Item:Sport Name%]')/fields

The call failed trying the Workflow. I think the problem is in the dictionaryActivities variable and its type. This is what web service returned as ResponseCode:

BadRequest

Any suggestion? What is the correct variable type to use in this case?

1 Answer 1

1

Create a tmp string as {"results": ["aaa","bbb","ccc"]}

Then, set Choices as dictionary and returnd from tmp string.

enter image description here

2
  • Great! It works! Do you know if it is possible to add this field to default view using the same REST call?
    – Pepozzo
    Nov 15, 2017 at 11:00
  • 1
    That's different endpoint: /_api/web/lists(guid'list id')/views(guid'view id')/ViewFields/AddField
    – Lee
    Nov 16, 2017 at 2:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.