Azure Cognitive Search - Create Data Souce via API - azure-cognitive-search

I have an azure cognitive search service that I am trying to add an azure blob storage data source via the api. Creating it works fine via the portal.
Here is the uri:
https://xxxxxx.search.windows.net/datasources?api-version=2019-05-06
Here are the headers:
User-Agent: Fiddler
Content-Type: application/json
api-key: XXXXXXXXXXXXXXXXXXXXXXXXXXXX
Host: XXXXXXXXXX.search.windows.net
Content-Length: 412
Here is the body:
{
"name" : "documents",
"description" : "documents data source",
"type" : "'azureblob",
"credentials" :
{ "connectionString" :
"XXXXXXXXX"
},
"container" : { "name" : "documents" }
}
When I run it, I get a 400 error code with the following message:
{"error":{"code":"","message":"Data source type ''azureblob' is not
supported"}}
I got the enum value straight from the docs here. Am I missing something?
Thanks in advance

So it was a copy/paste error from the docs:
"azureblob" <> "azureblob "

Related

Graph API: Using $filter with schema extensions data not working when request sent as part of a batch operation

According to the Graph API documentation, making a GET request to get groups with extension data that includes a filtered response is acceptable. For example, according to the doc referenced the following request should be valid:
GET https://graph.microsoft.com/v1.0/users/${id}/memberOf?$filter=graphlearn_courses/courseId eq ‘123’&$select=displayName,id,description,graphlearn_courses
This works when making the request as a singleton but fails and returns no response when the same request is made as part of a batch request:
POST https://graph.microsoft.com/v1.0/$batch
Accept: application/json
Content-Type: application/json
{
"requests": [
{
"id": "1",
"method": "GET",
"url": "/users/${id}/memberOf?$filter=graphlearn_courses/courseId eq ‘123’&$select=displayName,id,description,graphlearn_courses"
}
...
]
}
Can this be looked into and the issue resolved by someone at MS support please? Thank you in advance.
Schema extensions (legacy) are not returned with $select statement, but are returned without $select. So i would recommend you to try that and see if it helps. Documentation available # Microsoft Graph API limitations.

Deep insert in Odata v4 in Business Central AL Extension

We are creating an Extension in AL to import orders.
For this question we have simplified our extension to explain the challenges we are facing.
What we would like to do is import header + lines in Dynamics 365 Business Central.
To achive this we we have:
- Created a table (Header)
- Created a table (Lines)
- Created a page of Type API (Doc)
- Created a listPart (SalesLine)
Scenario 1
We have published page DOC and are trying to do a post request to this odata url.
POST https://api.businesscentral.dynamics.com/v1.0/{tennant}/Sandbox/ODataV4/Company('CRONUS%20NL')/Doc/ HTTP/1.1
Content-Type: application/json
Authorization: Basic {{username}} {{password}}
{
"name": "Description",
"SalesLines" : [{"lineno" : 1000}]
}
The response:
{
"error": {
"code": "BadRequest",
"message": "Does not support untyped value in non-open type."
}
}
Scenario 2
When we post:
POST https://api.businesscentral.dynamics.com/v1.0/3{tennant}/Sandbox/ODataV4/Company('CRONUS%20NL')/Doc/ HTTP/1.1
Content-Type: application/json
Authorization: Basic {{username}} {{password}}
{
"name": "Description"
}
We get the following response:
{
"#odata.context": "https://api.businesscentral.dynamics.com/v1.0/3ddcca3d-d343-4a06-95f9-f32dbf645199/Sandbox/ODataV4/$metadata#Company('CRONUS%20NL')/Doc/$entity",
"#odata.etag": "W/\"JzQ0O3BKUzExSUMrQUl4UXFQc2R6V1J1ellvZEttRTJoa2xhanNtV0M0K3Ezajg9MTswMDsn\"",
"id": 4,
"name": "Description",
"DateTime": "2019-05-20T19:33:13.73Z"
}
I have published our extension on GitHub
Help would be appriciated.
I have worked on a similar solution and found that the following things were required for it to work:
The part containing your lines must be placed inside the repeater on your header Page.
You must set the EntityName and EntitySetName on your part to the same values as on the actual page.
When calling the API you must append the parameter $expand=[EntitySetName of your lines part] e.g $expand=orderLines.
In the JSON body the property name of the array containing the lines must match the EntitySetName of the lines part.
I can provide some examples if the instructions above do not suffice.

Create datasource in azure search returns 403 Forbidden

I have a search service running on azure in a free tier. On this service I already have a datasource, and indexer and an index defined.
I'd like to add another datasource (and index + indexer). When I do this (using postman) I get 403 Forbidden without any other error message.
This is the POST I made to this url - https://my-search-service-name.search.windows.net/datasources?api-version=2016-09-01:
"Content-Type": "application/json",
"api-key": "API-KEY-HERE"
{
"name": "datasource-prod",
"description": "Data source for search",
"type": "azuresql",
"credentials": { "connectionString" : "Server=tcp:xxxx.database.windows.net,1433;Initial Catalog=xxxxx_prod;Persist Security Info=False;User ID=xxxxxx;Password=xxxxxx!;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" },
"container": {"name": "DataAggregatedView"},
"dataChangeDetectionPolicy": {
"#odata.type" : "#Microsoft.Azure.Search.HighWaterMarkChangeDetectionPolicy",
"highWaterMarkColumnName" : "ChangeIndicator"
},
"dataDeletionDetectionPolicy": {
"#odata.type" : "#Microsoft.Azure.Search.SoftDeleteColumnDeletionDetectionPolicy",
"softDeleteColumnName" : "isDeleted",
"softDeleteMarkerValue" : "0"
}
}
Using the same request, with different name and database name worked perfectly and generated the existing (first) datasource. This error (403) - not even got the error message - happens only when I try to define a second datasource.
As I can understand from documentation, free search tier allows 3 datasources. Anyone had this issue? Any help/direction is appreciate!
Thank you.
Make sure you're using the admin API key. It looks like you may be using a query key.

Error in webhook subscription api

I have followed the instruction for using the Outlook REST APIs webhook push notification.
I want push notification from the calendar for creating, updating and deleting event entities. I have called below request:
Method Type: Post
URL: https://outlook.office.com/api/v2.0/me/subscriptions
Content-Type : application/json
Authorization : Bearer ACCESS_TOKEN
Request Body :
{
"#odata.type": "#Microsoft.OutlookServices.PushSubscription",
"Resource": "https://outlook.office.com/api/beta/me/events",
"NotificationURL": "https://krogerfreshwebhook.ngrok.io/myNotifyClient",
"ChangeType": "Created",
"ClientState": "MySecretClientStateString"
}
But I am getting below error in response header
content-length : 0
date : Mon, 20 Nov 2017 12:58:03 GMT
request-id : 38ac0346-088f-4b43-80b2-32c6cf64b22c
status : 401
www-authenticate : Bearer client_id="00000002-0000-0ff1-ce00-000000000000", trusted_issuers="00000001-0000-0000-c000-000000000000#*", token_types="app_asserted_user_v1 service_asserted_app_v1", authorization_uri="https://login.windows.net/common/oauth2/authorize", error="invalid_token",Basic Realm="",Basic Realm="",Basic Realm=""
x-backendhttpstatus : 401, 401
x-beserver : MA1PR01MB0485
x-calculatedbetarget : MA1PR01MB0485.INDPRD01.PROD.OUTLOOK.COM
x-calculatedfetarget : MA1PR01CU001.internal.outlook.com
x-diaginfo : MA1PR01MB0485
x-feproxyinfo : MA1PR01CA0025.INDPRD01.PROD.OUTLOOK.COM
x-feserver : MA1PR01CA0025, BM1PR01CA0075
reason="ErrorCode: 'PP_E_RPS_CERT_NOT_FOUND'
Message:
'Certificate cannot be found. Certificate required for the operation cannot be found.%0d%0a
Internal error: spRPSTicket->ProcessToken failed.
Failed to call CRPSDataCryptImpl::UnpackData:Certificate cannot be found. Certificate required for the operation cannot be found.%0d%0a Internal error: Failed to decrypt data. :Failed to get session key. RecipientId=293577. spCache->GetCacheItem returns error.:Cert Name: (null).
error_category="invalid_msa_ticket"
x-msedge-ref : Ref A: 0C4DE404A07C474FA67DC1A986C2DEA0 Ref B: BOM01EDGE0220 Ref C: 2017-11-20T12:58:03Zenter code here
x-powered-by : ASP.NET
Additional Information:
Authorization URL:
login.microsoftonline.com/common/oauth2/v2.0/authorize
?response_type=code
&client_id=my_clinet_id
&redirect_uri=my_redirect_url
&authorize
&scope=openid,offline_access,User.ReadWrite,Mail.ReadWrite,Contacts.ReadWrite,Tasks.ReadWrite,Calendars.ReadWrite,Calendars.ReadWrite.Shared,Mail.Send,Group.Read.All,Files.ReadWrite,Files.ReadWrite.All
When I call calendar api then it is working fine. It is giving me event list of calendar but when I use the same token for subscription of push notification then it is giving me invalid token error

Can't get data from remote server by proxy engine

I met another strange issue in my work with ExtJS. I get JSON data from my folder myapp/data/users.json but when I change it to URL address pointed to remote server (http://myserver/users.json or .../getusers.php) I get none json data.
My code:
Ext.define('APP.store.Users', {
extend : 'Ext.data.Store',
model : 'APP.model.User',
autoLoad : true,
proxy : {
type : 'ajax',
url : 'http://myserver.com/users.json',
//api : {
// //read : 'data/users.json' // it works OK
//},
actionMethods: {
read: 'GET'
},
extraParams: {
action: 'someaction',
name: 'user'
},
noCache: false,
reader : {
type : 'json',
root : 'users',
successProperty : 'success',
getResponseData : function(r) {
console.log("RESPONSE in reader: ", r);
}
},
afterRequest : function(request, success) {
console.log(request, success); // success: either true or false
},
....
I have installed Apache server to use ExtJS and can load data for localhost/users.json with succ. I thought the problem can make my system. But I checked both for Windows XP and Windows 7 with turned firewall off. It didn't help.
Firebug -> Network shows Http code 200 for the remote address but in respone tab is no data (in this case json structue).
Request headers from Firebug:
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language pl,en-us;q=0.7,en;q=0.3
Access-Control-Request-He... x-requested-with
Access-Control-Request-Me... GET
Connection keep-alive
Host myserver.com // WAS CHANGED
Origin http://localhost
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1
I have no idea what can be wrogn. All seems to be ok.
Thank you for any hint.
Bogus
This is covered in the docs:
AjaxProxy cannot be used to retrieve data from other domains. If your
application is running on http://domainA.com it cannot load data from
http://domainB.com because browsers have a built-in security policy
that prohibits domains talking to each other via AJAX.
If you need to read data from another domain and can't set up a proxy
server (some software that runs on your own domain's web server and
transparently forwards requests to http://domainB.com, making it look
like they actually came from http://domainA.com), you can use
Ext.data.proxy.JsonP and a technique known as JSON-P (JSON with
Padding), which can help you get around the problem so long as the
server on http://domainB.com is set up to support JSON-P responses.
See JsonPProxy's introduction docs for more details.

Resources