简体   繁体   English

如何在Node(jsforce)中使用SOAP / REST API创建PushTopic

[英]How can you create a PushTopic with SOAP/REST API in Node (jsforce)

According to https://salesforce.stackexchange.com/questions/48901/create-streaming-pushtopic-using-rest-api I should be able to use the standard sobject API to create a PushTopic . 根据https://salesforce.stackexchange.com/questions/48901/create-streaming-pushtopic-using-rest-api的说明,我应该能够使用标准的sobject API创建PushTopic However when I do so I get an error of 但是,当我这样做时,我得到一个错误

The requested resource does not exist. 请求的资源不存在。

In fact, I can't even describe the object. 实际上,我什至无法描述对象。

I am using node and jsforce to test this. 我正在使用nodejsforce进行测试。 I have successfully used the execute anonymous apex code from the developer console to create a topic, but I require it to be done inside of my own server. 我已经成功地使用了developer consoleexecute anonymous apex code来创建主题,但是我要求它必须在我自己的服务器中完成。

My code looks like: 我的代码如下:

var jsforce = require('jsforce');
var config = {...};
var conn = new jsforce.Connection({
  oauth2 : {
    clientId : config.oauthClientId,
    clientSecret : config.oauthSecret,
    redirectUri : config.oauthCallbackUrl
  },
  instanceUrl : config.instanceUrl,
  accessToken : config.accessToken,
  refreshToken: config.refreshToken
});

conn
  .sobject('PushTopic')
  .describe()
  .then(function(ret){
    console.log('Description:', ret)
  }, function(err){
    console.log('Error:', err)
  });

I Get: 我得到:

Error { [NOT_FOUND: The requested resource does not exist] name: 'NOT_FOUND', errorCode: 'NOT_FOUND' } 错误{[[NOT_FOUND:请求的资源不存在]名称:'NOT_FOUND',错误代码:'NOT_FOUND'}

If I use 'Account' instead of 'PushTopic' I get: 如果我使用'Account'而不是'PushTopic''PushTopic'得到:

Description { actionOverrides: [], activateable: false, childRelationships: ... 说明{actionOverrides:[],可激活:false,childRelationships:...

Is this a problem with jsforce ? 这是jsforce的问题吗? Any ideas appreciated! 任何想法表示赞赏!

Ok. 好。 The problem was that my user did not have permissions for the PushTopic object. 问题是我的用户没有对PushTopic对象的权限。 Even though I can subscribe to the streaming channel that the topic's produce (streaming api enabled), you need additional permissions to create a topic. 即使我可以订阅主题产生的流媒体频道(启用了streaming api),也需要其他权限才能创建主题。

Setup -> Manage Users -> Permission Sets -> New -> Save -> Object Settings -> Push Topics -> Edit 设置->管理用户->权限集->新建->保存->对象设置->推送主题->编辑

Then 然后

Manage Assignments -> Add Assignments 管理分配->添加分配

I created a permission set called 'PushTopic_Creator' and only added that permission, and then applied it to my user. 我创建了一个名为“ PushTopic_Creator”的权限集,仅添加了该权限,然后将其应用于我的用户。 I can now describe and create PushTopics! 我现在可以描述和创建PushTopics!

According to this document supported calls for REST are: 根据本文档,对REST的支持为:

REST: DELETE, GET, PATCH, POST (query requests are specified in the URI) REST:DELETE,GET,PATCH,POST(在URI中指定查询请求)

Together with this, if you check samples in Workbench Streaming API config does not require Salesforce describe() call. 与此同时,如果您在Workbench Streaming API配置中检查示例,则不需要Salesforce describe()调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM