Autodesk Forge API createBucket无法正常工作(Autodesk Forge API createBucket not working)
我试图通过使用
autodesk-forge
forge -api构建一个应用程序。 首先,我在Autodesk配置中创建了一个应用程序,以接收进行API调用所需的“ClientID”和“Client Secret”。不知何故,当我尝试使用
createBucket
调用,这是文档在这里我得到一个答案bad request 400
,我不知道为什么。这是我的API调用:
let oAuth2TwoLegged = new ForgeSDK.AuthClientTwoLegged(clientId, clientSecret, [ 'data:read', 'data:write', 'bucket:create', 'bucket:read', 'data:write', 'data:read', 'viewables:read' ], autoRefresh); oAuth2TwoLegged.authenticate().then(function(credentials){ var HubsApi = new ForgeSDK.HubsApi(); //Hubs Client var BucketsApi = new ForgeSDK.BucketsApi(); //Buckets Client BucketsApi.createBucket({bucketKey :"Test", policyKey: "transient"},{}, oAuth2TwoLegged, credentials).then((response) => { console.log(' new BUCKET: ', response) }).catch((err) => { console.log('ERROR BLA: ', err) }); }).catch((err) => { console.log('oauth error: ', err) })
有没有人有一个建议,我可能做错了什么?
当我使用不同的电话时,例如:
BucketsApi.getBuckets({}, oAuth2TwoLegged, credentials).then(function(response){ console.log('buckets: ', response.body); }, function(err){ console.error(err); });
有用...
编辑
如果我执行以下操作:
BucketsApi.createBucket(xyda_select_rtl, {'bucketKey' :'xyda_select_rtl', 'policyKey': 'transient'}, oAuth2TwoLegged, credentials).then((response) => { console.log(' new BUCKET: ', response) }).catch((err) => { console.log('ERROR BLA: ', err) });
我得到
xyda_select_rtl
没有定义!?!当我添加:
var xyda_select_rtl;
Missing the required parameter 'postBuckets' when calling createBucket
,出现错误Missing the required parameter 'postBuckets' when calling createBucket
Ehhm ....是啊: - /
I'm trying to build an application by using the
autodesk-forge
-api's. To start with I created an App inside my Autodesk configuration to receive an "ClientID" and a "Client Secret" which are required to make API calls.Somehow, when I try to use the
createBucket
-API call, which is documentet here I get an answerbad request 400
and I dont't know why.here is my API call:
let oAuth2TwoLegged = new ForgeSDK.AuthClientTwoLegged(clientId, clientSecret, [ 'data:read', 'data:write', 'bucket:create', 'bucket:read', 'data:write', 'data:read', 'viewables:read' ], autoRefresh); oAuth2TwoLegged.authenticate().then(function(credentials){ var HubsApi = new ForgeSDK.HubsApi(); //Hubs Client var BucketsApi = new ForgeSDK.BucketsApi(); //Buckets Client BucketsApi.createBucket({bucketKey :"Test", policyKey: "transient"},{}, oAuth2TwoLegged, credentials).then((response) => { console.log(' new BUCKET: ', response) }).catch((err) => { console.log('ERROR BLA: ', err) }); }).catch((err) => { console.log('oauth error: ', err) })
Does anyone have a suggestion what I might doing wrong?
when I use a different call, for example this:
BucketsApi.getBuckets({}, oAuth2TwoLegged, credentials).then(function(response){ console.log('buckets: ', response.body); }, function(err){ console.error(err); });
it works...
EDIT
If I do the following:
BucketsApi.createBucket(xyda_select_rtl, {'bucketKey' :'xyda_select_rtl', 'policyKey': 'transient'}, oAuth2TwoLegged, credentials).then((response) => { console.log(' new BUCKET: ', response) }).catch((err) => { console.log('ERROR BLA: ', err) });
I get
xyda_select_rtl
is not defined!?!When I add:
var xyda_select_rtl;
I get the error
Missing the required parameter 'postBuckets' when calling createBucket
Ehhm.... yeah :-/
原文:https://stackoverflow.com/questions/47259842
最满意答案
正如Jean-Baptiste在他的评论中所说,如果你不想复制Blah的代码,将其封装到ExtBlah并调用Blah的方法。 请记住添加通用界面。 实际上,接口试图解决一些多继承问题。
Base +--[ ExtBase ] +--[ Blah ] implements BlahInterface +---[ Script1 ] +---[ Script2 ] +---[ ....... ] +---[ ScriptN ] +--[ ExtBlah: - private Blah instance] implements BlahInterface +---[ ScriptK ]
I also have a complication that the Base&ExtBase have init routines that prep db connections and other things which prevent me from instantiating multiple instances inheriting from Base.
Here is what I did.
Created a separate util-like class BaseUtil then in Blah&ExtBlah overrode init() like this :
@Override public void init() { super.init(); util = new BaseUtil(this.shared1, this.shared2, ....); }
/Now Blah extends Base, ExtBlah extends ExtBase and BaseUtil contains all shared functionality, but still can behave like Base because I pass all shared attributes, w/o the need to call init() twice/.
So the idea is to create instance of object which holds all shared functionality i.e. not duplicating code, but duplicating attributes instead. BaseUtil is outside of the hierarchy.
PS> This will probably be awkward if you have too many shared attributes. Also if you don't want to change the original scripts to use "util.method()" you can delegate all the methods.
相关问答
更多-
它的实现已定义。 C ++ 11在标准的实现数量部分给出了建议的最小值: - 直接和间接基类[16 384]。 - 单个类的直接基类[1 024]。 [...] - 一个班级的直接和间接虚拟基地[1 024]。 我会说这非常慷慨。 It's implementation defined. C++11 gives recommended minimums in the Implementation quantities section of the standard: — Direct and indirec ...
-
java中的多重继承(Multiple Inheritance in java)[2022-10-27]
这是Java的设计决定 。 你永远不会得到它,所以不要太担心它。 虽然MI可能会帮助你制作Mixins,但这是你唯一的良好MI。 It was a design decision of Java. You'll never get it, so don't worry too much about it. Although MI might help you make Mixins, that's the only good MI will ever do you. -
PHP中的多重继承(Multiple Inheritance in PHP)[2022-08-20]
Alex,大多数时候你需要多重继承是一个信号,你的对象结构有些不正确。 在你概述的情况下,我看到你的班级责任太广泛了。 如果Message是应用程序业务模型的一部分,它不应该关心渲染输出。 相反,您可以分离责任并使用发送使用文本或HTML后端传递的消息的MessageDispatcher。 我不知道你的代码,但让我以这种方式模拟: $m = new Message(); $m->type = 'text/html'; $m->from = 'John Doe'; $m->t ... -
Extjs多重继承?(Extjs multiple inheritance?)[2022-09-08]
你真正需要研究的是ExtJS插件。 /** * Boilerplate code taken from 'ExtJS in Action' by Jay Garcia */ YourNameSpace.RestGridPlugin = Ext.extend(Object, { constructor : function(config) { config = config || {}; Ext.apply(this.config); }, init : function(p ... -
教科书解决方案涉及多个虚拟继承。 class SDLBullet : public virtual Bullet { void draw() {/*draw me using SDL*/}; }; class EnemyBullet : public virtual Bullet { bool collision(Entity) {/*if Entity is a fellow enemy, don't collide*/}; }; class SDLEnemyBullet : public S ...
-
如何避免多重继承?(How to avoid multiple inheritance?)[2023-11-30]
Java8为接口引入了默认和静态方法。 在某种程度上,这允许多重继承。 但最有可能的是,正确的解决方案是重新设计您的设计。 你看,继承不是代码重用。 它是关于创建有用的抽象; 并且充分利用多态性。 就你的情况而言:也许这些功能可能/应该放入较小的界面; 然后分隔成自己的独立课程。 然后你使用对象的组合而不是继承来构建你需要的东西。 Java8 introduced default and static methods for interfaces. To a certain degree, that all ... -
多重继承(Multiple Inheritance)[2023-01-11]
继承两次 对于双重继承,你有一个歧义 - 编译器无法知道你想要使用哪两个A基。 如果你想拥有两个A基(有时你可能想要这样做),你可以通过转换为B或C来选择它们。这里默认转换最合适的是static_cast (作为最弱的可用),但它是不需要(它仍然比你的情况需要更强),因为你没有强制转换为派生类型。 自定义safe_cast模板应该完成这项工作: /// cast using implicit conversions only templateinline To ... -
否。接口定义了实现应该如何与外部世界通信,而不是定义任何行为。 您当然可以实现多个接口,但这并不意味着您有多个继承,只是实现接口的类可以显示为不同的东西。 No. An interface defines how an implementation should communicate with the outside world you do not define any behavior. You can of course implement multiple interfaces but that ...
-
让我们回顾一下您在代码中实际拥有的内容。 在这里,您声明接口A和嵌套类AClass : public interface A { class Aclass { int constants = 100; public void display() { System.out.println("Inside A"); } } public void display(); } 在这里,您声明接口B和嵌套 ...
-
多重继承的排序?(Sort of multiple inheritance?)[2024-02-16]
正如Jean-Baptiste在他的评论中所说,如果你不想复制Blah的代码,将其封装到ExtBlah并调用Blah的方法。 请记住添加通用界面。 实际上,接口试图解决一些多继承问题。 Base +--[ ExtBase ] +--[ Blah ] implements BlahInterface +---[ Script1 ] +---[ Script2 ] +---[ ....... ] +---[ ScriptN ] +--[ ...