I am using the Salesforce REST APIs to create a Contact and then an associated User. If I allow the creation of a User (via SCIMv2) to create an Account and Contact automatically (as details at link), the creation works. Unfortunately, I need to populate a custom field in the Contact and must create it separately.
The link also states that I can include the AccountId and ContactId to prevent the auto-creation. To do this I include the specified Account and Contact in the SCIMv2 JSON as shown below.
{
"schemas" : [ "urn:ietf:params:scim:schemas:core:2.0:User", "urn:salesforce:schemas:extension:external:2.0", "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User" ],
"userName" : "fred.bloggs#example.com",
"name" : {
"familyName" : "Bloggs",
"givenName" : "Fred"
},
"emails" : [ {
"type" : "work",
"primary" : true,
"value" : "fred.bloggs#example.com"
} ],
"preferredLanguage" : "en_US",
"locale" : "en_AU",
"timezone" : "Australia/Hobart",
"active" : true,
"entitlements" : [ {
"value" : "00e5j000000md3VAAQ"
} ],
"urn:salesforce:schemas:extension:external:2.0" : {
"contactId" : "0039D00000JBLfvQAH",
"accountId" : "0019D00000OkFMYQA3"
}
}
When I make this request I get an error response from Salesforce:
Response Status:400 - Insert failed. First exception on row 0; first error: DUPLICATES_DETECTED, You're creating a duplicate record. We recommend you use an existing record instead.
Since there is definitely not a User object already in the system for this user, I am assuming it's trying to create the Contact again and failing.
Any help to understand what is happening and what I am doing wrong would be appreciated.
Related
I have added console logs in the schema file, and retrieved data from the database by running meteor mongo :
{ "_id" : ObjectId("5f0d8af2b08fc89eadef0dd1"), "title" : "Hello world!" }
{ "_id" : ObjectId("5f0d8af9b08fc89eadef0dd2"), "title" : "Hello world!s" }
{ "_id" : ObjectId("5f0d9449b08fc89eadef0dd3"), "title" : "Hello world!s" }
{ "_id" : ObjectId("5f0f2d7eb08fc89eadef0dd4"), "title" : "Task1" }
and still, the same data is retrieved via the server-side through a console log I added on the subscription function:
Schema.js
if (Meteor.isServer) {
Meteor.publish('tasks', function task() {
console.log(Tasks.find({}).fetch(),' ttttttttttttttttttttttt');
return Tasks.find({}).fetch();
});
}
Then when I try to return the same data in another file, it actually fails to return the data and instead returns this in the console:
[] "These are the results"
Get.js
const getAllTasks=()=>{
sub=Meteor.subscribe('tasks').ready();
const tasks = Tasks.find({}).fetch();
console.log(tasks, 'These are the results');
return tasks
}
Here's my file structure
Question
Please help me figure out what I am potentially doing wrong?
Are you exposing the pub to your client? Download meteor dev tools (I know this is on chrome but not sure of other browsers) and you can see which publications are reaching your client and what in your db the client has access to.
Due to a bug in the Azure portal, I am needing to create an Azure Cognitive Search data source, index, and indexer programmatically using the REST API. There were no issues creating the data source or index, but the POST request below returns the following error.
{
"error": {
"code": "",
"message": "The request is invalid. Details: dataSource : A resource without a type name was found, but no expected type was specified. To allow entries without type information, the expected type must also be specified when the model is specified.\r\n"
}
}
The following POST request is a modified example found on this page, with the variables replaced with the correct names of the service-name, admin-key, dataSourceName and targetIndexName.
POST request (using postman)
POST https://SERVICENAME.search.windows.net/indexers?api-version=2019-05-06
Content-Type: application/json
api-key: ADMINKEY
{
"name" : "my-json-indexer",
"dataSourceName" : "BLOBDATASOURCE",
"targetIndexName" : "TARGETINDEX",
"schedule" : { "interval" : "PT2H" },
"parameters" : { "configuration" : { "parsingMode" : "json" } }
}
Seems that when you've created your data source, the type property was not provided.
Here's the two requests:
Create data source
POST https://[service name].search.windows.net/datasources?api-version=2019-05-06
Content-Type: application/json
api-key: [admin key for Azure Cognitive Search]
{
"name" : "my-blob-datasource",
"type" : "azureblob",
"credentials" : { "connectionString" : "DefaultEndpointsProtocol=https;AccountName=<account name>;AccountKey=<account key>;" },
"container" : { "name" : "my-container", "query" : "optional, my-folder" }
}
Create indexer
POST https://[service name].search.windows.net/indexers?api-version=2019-05-06
Content-Type: application/json
api-key: [admin key for Azure Cognitive Search]
{
"name" : "my-json-indexer",
"dataSourceName" : "my-blob-datasource",
"targetIndexName" : "my-target-index",
"schedule" : { "interval" : "PT2H" },
"parameters" : { "configuration" : { "parsingMode" : "json" } },
"fieldMappings" : [
{ "sourceFieldName" : "/article/text", "targetFieldName" : "text" },
{ "sourceFieldName" : "/article/datePublished", "targetFieldName" : "date" },
{ "sourceFieldName" : "/article/tags", "targetFieldName" : "tags" }
]
}
I want to set the createdDate for a new feed-element (via SalesForce Rest API).
I tried to do this:
{
"body" : {
"messageSegments" : [
{
"type" : "Text",
"text" : "When should we meet for release planning? "
}]
},
"feedElementType" : "FeedItem",
"subjectId" : "0060Y00000XYZXYZ",
"createdDate ": "2016-10-27T08:01:56.000Z"
}
But I get this error message:
[
{
"errorCode": "JSON_PARSER_ERROR",
"message": "Unrecognized field \"createdDate \" at [line:-1, column:-1]"
}
]
I read that I can set the createdDate via API (https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_resources_feed_element.htm), but I don't find a example or a way to do this.
Also I tried to set the createdDate in a update request, but the same result.
I hope someone can help me. Thanks!
How can I get in a call back after inserting a file using collectionFS the key value?
Images.insert(file, function (err, fileObj) {
if (err) {
console.log(err);
} else {
console.log('success', fileObj);
setTimeout(function () {
console.log('url', fileObj.url());
let url = fileObj.url('images');
$scope.slideshows.url = `${url}`
$scope.$apply();
}, 2000);
}
});
I'm building a cms which handles file uploads to show in different apps, I'm able to see the uploaded file using {{image.url}} in the cms but I'm unable to view the images uploaded using this method in the other apps.
Every app is connecting to the same database and I'm uploading the images into my server using:
Images = new FS.Collection("images", {
stores: [new FS.Store.FileSystem("images", {path: '/home/uploadedimages'})]
});
I'm then using nginx to serve those images so I can access them via http://domain.com/uploadedimages.
In order to fix my problem I need to somehow get the key value in this schema stored by collectionFS:
{
"_id" : "5BEe4maLCMFtHAZAj",
"original" : {
"name" : "wantedposter.jpg",
"updatedAt" : ISODate("2016-05-19T13:34:32.050Z"),
"size" : 28828,
"type" : "image/jpeg"
},
"uploadedAt" : ISODate("2016-05-19T21:30:54.299Z"),
"copies" : {
"images" : {
"name" : "wantedposter.jpg",
"type" : "image/jpeg",
"size" : 28828,
"key" : "images-5BEe4maLCMFtHAZAj-wantedposter.jpg",
"updatedAt" : ISODate("2016-05-19T21:30:54Z"),
"createdAt" : ISODate("2016-05-19T21:30:54Z")
}
}
}
So I can do /uploadedimages/:key
QUESTION
Is there a way to get the key value from collectionFS?
It is not clear to me the best practice for maintaining $scope of objects when making calls to a RESTful API. The problem I'm having is working with a Schema that has nested sub arrays, see below.
Is it best practice when making RESTful API call to expect a full JSON document in the response to update the $scope, or should I be able to maintain $scope on the client with Angular with nothing more than a http response code (ie 200)? It makes sense when making updates to the user object, but when I need to update profiles or favorites sections of the document, I'm just passing that portion of the document to the API and getting an http reponse code back, and my $scope doesn't reflect with the change, especially when pushing or pulling over PATCH route.
{
"_id" : ObjectId("558d53eebdd9804820090fa1"),
"name" : "Frank",
"email" : "Frank#FrankTheTank.com",
"profiles" : [
{
"avatar" : "div-male",
"age" : "35",
"gender" : "Male",
"profilename" : "Oly Lifter",
"_id" : ObjectId("558d5404bdd9804820090fa2"),
"favorites" : [
{
"name" : "Power Clean"
},
{
"name" : "Hang Clean"
},
{
"name" : "Clean and Jerk"
}
],
"createdAt" : ISODate("2015-06-26T13:30:44.661Z")
}
],
"createdAt" : ISODate("2015-06-26T13:30:22.884Z"),
"role" : "user"
}