1

I have successfully used a REST call to create a list item in my root site and now need to use a second one to populate a list item in a sub site with the same data.

Here are my dictionary settings

Site Creation Call:

header

content-type - string - application/json;odata=verbose

accept - string - application/json;odata=verbose

metadata

type - string - SP.Data.[variable: TargetList]ListItem

JSONRequest

__metadata - dictionary - [variable: metadata]

site creation parameters:

parameters

parameters - dictionary - [variable: JSONRequest]

HTTP Call Settings

[variable: TargetURL]/_api/web/lists/getbytitle('[variable TargetList]')/items

Call Type: POST

This renders a link in the format:

http://server/rootsite/_api/web/lists/getbytitle('listname')/items

this works fine for the root site but fails with a bad request error when I add the sub site in like this:

http://server/rootsite/web/_api/web/lists/getbytitle('listname')/items

Is there a different format I should be using for the connections to sub sites or is it that I'm trying to undertake 2 REST calls with the same workflow?

11
  • Check if you are getting the metadata property correct or not? Commented Jul 30, 2019 at 15:10
  • You can verify it is correct or not using /_api/web/lists/GetByTitle('listName')/ListItemEntityTypeFullName. Commented Jul 31, 2019 at 4:39
  • how are you passing the subsite url
    – Sunil Sahu
    Commented Jul 31, 2019 at 6:29
  • @SunilSahu I have a variable called TargetSiteURL which holds the root URL: server/sites/mysite. That is all I use in the first workflow (the functioning one) in the second workflow I add a second variable (SiteTitle) to give the following URL structure for the subsite server/sites/mysite/<variable:subsite title>/
    – JonS
    Commented Jul 31, 2019 at 10:52
  • 1
    yes, I know just wanted you to check whether the url formation is correct or not. So with hardcoding the url
    – Sunil Sahu
    Commented Aug 1, 2019 at 10:36

1 Answer 1

0

sometimes, SharePoint gives you more details on your error in the response Body.

Does SharePoint returns HTTP 400 only ? Can you give us more details ?

2
  • All SharePoint tells me is BadRequest. When I run the call in Fiddler I get a 403 permissions error but I am the SCA and in the Owners group and the subsite inherits permissions for the root. There are no app steps or elevated permissions present so everything should be running against my user account permissions which are Full Control.
    – JonS
    Commented Aug 1, 2019 at 10:11
  • you should open your rest call error result and expand the returned "data" parameter and search for the different errors.
    – Mike
    Commented Aug 2, 2019 at 22:24

Your Answer

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

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