首页 \ 问答 \ Autodesk Forge API createBucket无法正常工作(Autodesk Forge API createBucket not working)

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 answer bad 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
更新时间:2022-04-29 21:04

最满意答案

正如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的设计决定 。 你永远不会得到它,所以不要太担心它。 虽然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.
  • Alex,大多数时候你需要多重继承是一个信号,你的对象结构有些不正确。 在你概述的情况下,我看到你的班级责任太广泛了。 如果Message是应用程序业务模型的一部分,它不应该关心渲染输出。 相反,您可以分离责任并使用发送使用文本或HTML后端传递的消息的MessageDispatcher。 我不知道你的代码,但让我以这种方式模拟: $m = new Message(); $m->type = 'text/html'; $m->from = 'John Doe '; $m->t ...
  • 你真正需要研究的是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 ...
  • Java8为接口引入了默认和静态方法。 在某种程度上,这允许多重继承。 但最有可能的是,正确的解决方案是重新设计您的设计。 你看,继承不是代码重用。 它是关于创建有用的抽象; 并且充分利用多态性。 就你的情况而言:也许这些功能可能/应该放入较小的界面; 然后分隔成自己的独立课程。 然后你使用对象的组合而不是继承来构建你需要的东西。 Java8 introduced default and static methods for interfaces. To a certain degree, that all ...
  • 继承两次 对于双重继承,你有一个歧义 - 编译器无法知道你想要使用哪两个A基。 如果你想拥有两个A基(有时你可能想要这样做),你可以通过转换为B或C来选择它们。这里默认转换最合适的是static_cast (作为最弱的可用),但它是不需要(它仍然比你的情况需要更强),因为你没有强制转换为派生类型。 自定义safe_cast模板应该完成这项工作: /// cast using implicit conversions only template inline 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和嵌套 ...
  • 正如Jean-Baptiste在他的评论中所说,如果你不想复制Blah的代码,将其封装到ExtBlah并调用Blah的方法。 请记住添加通用界面。 实际上,接口试图解决一些多继承问题。 Base +--[ ExtBase ] +--[ Blah ] implements BlahInterface +---[ Script1 ] +---[ Script2 ] +---[ ....... ] +---[ ScriptN ] +--[ ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。