Récupérer un FormDigestValue
Requête:
POST /hubs/{hub}/_api/contextinfo
Entêtes:
Cookie: FedAuth Cookie get after login
Accept: application/json;odata=verbose
Accept: application/json;odata=verbose
Réponse:
{
"d":
{
"GetContextWebInformation":
{
"__metadata": {
"type": "SP.ContextWebInformation"
},
"FormDigestTimeoutSeconds": 1799,
"FormDigestValue": "{FormDigestValue}",
"LibraryVersion": "15.0.4957.1000",
"SiteFullUrl": "....",
"SupportedSchemaVersions": {
"__metadata": {
"type": "Collection(Edm.String)"
},
"results":[
"14.0.0.0",
"15.0.0.0"
]
},
"WebFullUrl": "....."
}
}
}
"d":
{
"GetContextWebInformation":
{
"__metadata": {
"type": "SP.ContextWebInformation"
},
"FormDigestTimeoutSeconds": 1799,
"FormDigestValue": "{FormDigestValue}",
"LibraryVersion": "15.0.4957.1000",
"SiteFullUrl": "....",
"SupportedSchemaVersions": {
"__metadata": {
"type": "Collection(Edm.String)"
},
"results":[
"14.0.0.0",
"15.0.0.0"
]
},
"WebFullUrl": "....."
}
}
}
Note: Vous devez conserver la valeur FormDigestValue pour l'utiliser dans les POST de mise à jour des éléments
Créer un élément
Requête:
POST /hubs/{hub}/_api/web/lists/getbytitle('{ListTitle}')/items
Entêtes:
Cookie: Cookie FedAuth
Accept: application/json;odata=verbose
Content-Type: application/json;odata=verbose
X-RequestDigest: Token FormDigestValue
Accept: application/json;odata=verbose
Content-Type: application/json;odata=verbose
X-RequestDigest: Token FormDigestValue
Corps:
{
'__metadata': {
'type': 'The value of the content type you get in the item metadata'
},
'field1': 'Value1',
'field2': 'Value2'
}
'__metadata': {
'type': 'The value of the content type you get in the item metadata'
},
'field1': 'Value1',
'field2': 'Value2'
}
Update a list item
Requête:
PUT /hubs/{hub}/_api/web/lists/getbytitle('{ListTitle}')/items({ItemID})
Entêtes:
Cookie: Cookie FedAuth
Accept: application/json;odata=verbose
Content-Type: application/json;odata=verbose
X-HTTP-Method: MERGE
X-RequestDigest: Token FormDigestValue
IF-MATCH: *
Accept: application/json;odata=verbose
Content-Type: application/json;odata=verbose
X-HTTP-Method: MERGE
X-RequestDigest: Token FormDigestValue
IF-MATCH: *
Corps:
{
'__metadata': {
'type': 'The value of the content type you get in the item metadata'
},
'field1': 'Value1',
'field2': 'Value2'
}
'__metadata': {
'type': 'The value of the content type you get in the item metadata'
},
'field1': 'Value1',
'field2': 'Value2'
}
Supprimer un élément de liste
Requête:
PUT /hubs/{hub}/_api/web/lists/getbytitle('{ListTitle}')/items({ItemID})
Entêtes:
Cookie: Cookie FedAuth
X-HTTP-Method: DELETE
X-RequestDigest: Token FormDigestValue
IF-MATCH: *
X-HTTP-Method: DELETE
X-RequestDigest: Token FormDigestValue
IF-MATCH: *