Выберите разрешение или разрешения, помеченные как наименее привилегированные для этого API. Используйте более привилегированное разрешение или разрешения только в том случае, если это требуется приложению. Дополнительные сведения о делегированных разрешениях и разрешениях приложений см. в разделе Типы разрешений. Дополнительные сведения об этих разрешениях см. в справочнике по разрешениям.
Ниже показан пример запроса.
POST https://graph.microsoft.com/beta/search/bookmarks
Content-Type: application/json
{
"displayName": "Contoso Install Site",
"webUrl": "http://www.contoso.com/",
"description": "Try or buy Contoso for Home or Business and view product information",
"keywords": {
"keywords": ["Contoso", "install"],
"reservedKeywords": ["Unique keyword"],
"matchSimilarKeywords": true
},
"availabilityStartDateTime": null,
"availabilityEndDateTime": null,
"platforms": ["windows"],
"targetedVariations": [
{
"languageTag": "es-es",
"displayName": "Sitio de instalación Contoso",
"description": "Pruebe o compre Contoso hogar o negocios y vea la información del producto"
}
],
"state": "published"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models.Search;
using Microsoft.Graph.Beta.Models;
var requestBody = new Bookmark
{
DisplayName = "Contoso Install Site",
WebUrl = "http://www.contoso.com/",
Description = "Try or buy Contoso for Home or Business and view product information",
Keywords = new AnswerKeyword
{
Keywords = new List<string>
{
"Contoso",
"install",
},
ReservedKeywords = new List<string>
{
"Unique keyword",
},
MatchSimilarKeywords = true,
},
AvailabilityStartDateTime = null,
AvailabilityEndDateTime = null,
Platforms = new List<DevicePlatformType?>
{
DevicePlatformType.Android,
},
TargetedVariations = new List<AnswerVariant>
{
new AnswerVariant
{
LanguageTag = "es-es",
DisplayName = "Sitio de instalación Contoso",
Description = "Pruebe o compre Contoso hogar o negocios y vea la información del producto",
},
},
State = AnswerState.Published,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Search.Bookmarks.PostAsync(requestBody);
mgc-beta search bookmarks create --body '{\
"displayName": "Contoso Install Site",\
"webUrl": "http://www.contoso.com/",\
"description": "Try or buy Contoso for Home or Business and view product information",\
"keywords": {\
"keywords": ["Contoso", "install"],\
"reservedKeywords": ["Unique keyword"],\
"matchSimilarKeywords": true\
},\
"availabilityStartDateTime": null,\
"availabilityEndDateTime": null,\
"platforms": ["windows"],\
"targetedVariations": [\
{\
"languageTag": "es-es",\
"displayName": "Sitio de instalación Contoso",\
"description": "Pruebe o compre Contoso hogar o negocios y vea la información del producto"\
}\
],\
"state": "published"\
}\
'
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodelssearch "github.com/microsoftgraph/msgraph-beta-sdk-go/models/search"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodelssearch.NewBookmark()
displayName := "Contoso Install Site"
requestBody.SetDisplayName(&displayName)
webUrl := "http://www.contoso.com/"
requestBody.SetWebUrl(&webUrl)
description := "Try or buy Contoso for Home or Business and view product information"
requestBody.SetDescription(&description)
keywords := graphmodelssearch.NewAnswerKeyword()
keywords := []string {
"Contoso",
"install",
}
keywords.SetKeywords(keywords)
reservedKeywords := []string {
"Unique keyword",
}
keywords.SetReservedKeywords(reservedKeywords)
matchSimilarKeywords := true
keywords.SetMatchSimilarKeywords(&matchSimilarKeywords)
requestBody.SetKeywords(keywords)
availabilityStartDateTime := null
requestBody.SetAvailabilityStartDateTime(&availabilityStartDateTime)
availabilityEndDateTime := null
requestBody.SetAvailabilityEndDateTime(&availabilityEndDateTime)
platforms := []graphmodels.DevicePlatformTypeable {
devicePlatformType := graphmodels.WINDOWS_DEVICEPLATFORMTYPE
requestBody.SetDevicePlatformType(&devicePlatformType)
}
requestBody.SetPlatforms(platforms)
answerVariant := graphmodelssearch.NewAnswerVariant()
languageTag := "es-es"
answerVariant.SetLanguageTag(&languageTag)
displayName := "Sitio de instalación Contoso"
answerVariant.SetDisplayName(&displayName)
description := "Pruebe o compre Contoso hogar o negocios y vea la información del producto"
answerVariant.SetDescription(&description)
targetedVariations := []graphmodelssearch.AnswerVariantable {
answerVariant,
}
requestBody.SetTargetedVariations(targetedVariations)
state := graphmodels.PUBLISHED_ANSWERSTATE
requestBody.SetState(&state)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
bookmarks, err := graphClient.Search().Bookmarks().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.models.search.Bookmark bookmark = new com.microsoft.graph.beta.models.search.Bookmark();
bookmark.setDisplayName("Contoso Install Site");
bookmark.setWebUrl("http://www.contoso.com/");
bookmark.setDescription("Try or buy Contoso for Home or Business and view product information");
com.microsoft.graph.beta.models.search.AnswerKeyword keywords = new com.microsoft.graph.beta.models.search.AnswerKeyword();
LinkedList<String> keywords1 = new LinkedList<String>();
keywords1.add("Contoso");
keywords1.add("install");
keywords.setKeywords(keywords1);
LinkedList<String> reservedKeywords = new LinkedList<String>();
reservedKeywords.add("Unique keyword");
keywords.setReservedKeywords(reservedKeywords);
keywords.setMatchSimilarKeywords(true);
bookmark.setKeywords(keywords);
bookmark.setAvailabilityStartDateTime(null);
bookmark.setAvailabilityEndDateTime(null);
LinkedList<DevicePlatformType> platforms = new LinkedList<DevicePlatformType>();
platforms.add(DevicePlatformType.Android);
bookmark.setPlatforms(platforms);
LinkedList<com.microsoft.graph.beta.models.search.AnswerVariant> targetedVariations = new LinkedList<com.microsoft.graph.beta.models.search.AnswerVariant>();
com.microsoft.graph.beta.models.search.AnswerVariant answerVariant = new com.microsoft.graph.beta.models.search.AnswerVariant();
answerVariant.setLanguageTag("es-es");
answerVariant.setDisplayName("Sitio de instalación Contoso");
answerVariant.setDescription("Pruebe o compre Contoso hogar o negocios y vea la información del producto");
targetedVariations.add(answerVariant);
bookmark.setTargetedVariations(targetedVariations);
bookmark.setState(com.microsoft.graph.beta.models.search.AnswerState.Published);
com.microsoft.graph.models.search.Bookmark result = graphClient.search().bookmarks().post(bookmark);
const options = {
authProvider,
};
const client = Client.init(options);
const bookmark = {
displayName: 'Contoso Install Site',
webUrl: 'http://www.contoso.com/',
description: 'Try or buy Contoso for Home or Business and view product information',
keywords: {
keywords: ['Contoso', 'install'],
reservedKeywords: ['Unique keyword'],
matchSimilarKeywords: true
},
availabilityStartDateTime: null,
availabilityEndDateTime: null,
platforms: ['windows'],
targetedVariations: [
{
languageTag: 'es-es',
displayName: 'Sitio de instalación Contoso',
description: 'Pruebe o compre Contoso hogar o negocios y vea la información del producto'
}
],
state: 'published'
};
await client.api('/search/bookmarks')
.version('beta')
.post(bookmark);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Search\Bookmark;
use Microsoft\Graph\Beta\Generated\Models\Search\AnswerKeyword;
use Microsoft\Graph\Beta\Generated\Models\DevicePlatformType;
use Microsoft\Graph\Beta\Generated\Models\Search\AnswerVariant;
use Microsoft\Graph\Beta\Generated\Models\Search\AnswerState;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Bookmark();
$requestBody->setDisplayName('Contoso Install Site');
$requestBody->setWebUrl('http://www.contoso.com/');
$requestBody->setDescription('Try or buy Contoso for Home or Business and view product information');
$keywords = new AnswerKeyword();
$keywords->setKeywords(['Contoso', 'install', ]);
$keywords->setReservedKeywords(['Unique keyword', ]);
$keywords->setMatchSimilarKeywords(true);
$requestBody->setKeywords($keywords);
$requestBody->setAvailabilityStartDateTime(null);
$requestBody->setAvailabilityEndDateTime(null);
$requestBody->setPlatforms([new DevicePlatformType('windows'), ]);
$targetedVariationsAnswerVariant1 = new AnswerVariant();
$targetedVariationsAnswerVariant1->setLanguageTag('es-es');
$targetedVariationsAnswerVariant1->setDisplayName('Sitio de instalación Contoso');
$targetedVariationsAnswerVariant1->setDescription('Pruebe o compre Contoso hogar o negocios y vea la información del producto');
$targetedVariationsArray []= $targetedVariationsAnswerVariant1;
$requestBody->setTargetedVariations($targetedVariationsArray);
$requestBody->setState(new AnswerState('published'));
$result = $graphServiceClient->search()->bookmarks()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Search
$params = @{
displayName = "Contoso Install Site"
webUrl = "http://www.contoso.com/"
description = "Try or buy Contoso for Home or Business and view product information"
keywords = @{
keywords = @(
"Contoso"
"install"
)
reservedKeywords = @(
"Unique keyword"
)
matchSimilarKeywords = $true
}
availabilityStartDateTime = $null
availabilityEndDateTime = $null
platforms = @(
"windows"
)
targetedVariations = @(
@{
languageTag = "es-es"
displayName = "Sitio de instalación Contoso"
description = "Pruebe o compre Contoso hogar o negocios y vea la información del producto"
}
)
state = "published"
}
New-MgBetaSearchBookmark -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.search.bookmark import Bookmark
from msgraph_beta.generated.models.search.answer_keyword import AnswerKeyword
from msgraph_beta.generated.models.device_platform_type import DevicePlatformType
from msgraph_beta.generated.models.search.answer_variant import AnswerVariant
from msgraph_beta.generated.models.answer_state import AnswerState
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Bookmark(
display_name = "Contoso Install Site",
web_url = "http://www.contoso.com/",
description = "Try or buy Contoso for Home or Business and view product information",
keywords = AnswerKeyword(
keywords = [
"Contoso",
"install",
],
reserved_keywords = [
"Unique keyword",
],
match_similar_keywords = True,
),
availability_start_date_time = None,
availability_end_date_time = None,
platforms = [
DevicePlatformType.Android,
],
targeted_variations = [
AnswerVariant(
language_tag = "es-es",
display_name = "Sitio de instalación Contoso",
description = "Pruebe o compre Contoso hogar o negocios y vea la información del producto",
),
],
state = AnswerState.Published,
)
result = await graph_client.search.bookmarks.post(request_body)
Ниже приводится пример отклика.