Created
April 28, 2017 14:40
-
-
Save vman/0bbf85b94715895d8ff3cd19ffbfecf0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async createListItem() { | |
try { | |
const spOpts: ISPHttpClientOptions = { | |
body: `{ Title: 'My New Item' }` | |
}; | |
const response = await this.context.spHttpClient.post(`https://tenant.sharepoint.com/sites/anothersitecollection/_api/web/lists/GetByTitle('test')/items`, SPHttpClient.configurations.v1, spOpts); | |
if (!response.ok) { | |
const responseText = await response.text(); | |
throw new Error(responseText); | |
}; | |
const responseJSON = await response.json(); | |
console.log(responseJSON); | |
} catch (error) { | |
console.log(error); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment