首页 \ 问答 \ 无法使用autodesk forge derivativesApi翻译创建的对象(Unable to translate created object using autodesk forge derivativesApi)

无法使用autodesk forge derivativesApi翻译创建的对象(Unable to translate created object using autodesk forge derivativesApi)

我试图翻译一个对象上传后,但我不断收到400 Bad Request错误。

我正在使用forge-api-nodejs-client

这里是我的代码的样子

          var base64 = require('js-base64').Base64;

          objectsApi.uploadObject(
            bucket.bucketKey,
            file.originalname,
            file.size,
            file.buffer,
            {},
            oAuth2TwoLegged,
            credentials
          )
          .then(
            response => {
              const objectDetails = response.body;

              // objectId => urn:adsk.objects:os.object:d62db090-0c47-11e8-9a36-7bd06cedf058/Pawn.stl

              const job = {
                input: {
                  urn: base64.encode(objectDetails.objectId)
                },
                output: {
                  formats: [
                    {
                      type: "obj"
                    }
                  ]
                }
              };
              derivativesApi
                .translate(job, {}, oAuth2TwoLegged, credentials)
                .then(
                  data => {
                    res.send(data);
                  },
                  err => {
                    // it fails here with 400 status error
                    res.send(err);
                  }
                );
            },
            err => {
              res.send(err);
            }
          );

我的job对象如下所示:

{
  input:{
    urn: 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6ZDYyZGIwOTAtMGM0Ny0xMWU4LTlhMzYtN2JkMDZjZWRmMDU4L1Bhd24uc3Rs'
  },
  output: {
    formats: [
      type: "obj"
    ]
  }
}

响应

{
  statusCode: 400,
  statusMessage: "Bad Request"
}

I am trying to translate an object after uploading it but I keep getting 400 Bad Request error.

I am using the forge-api-nodejs-client

here is how my code looks like

          var base64 = require('js-base64').Base64;

          objectsApi.uploadObject(
            bucket.bucketKey,
            file.originalname,
            file.size,
            file.buffer,
            {},
            oAuth2TwoLegged,
            credentials
          )
          .then(
            response => {
              const objectDetails = response.body;

              // objectId => urn:adsk.objects:os.object:d62db090-0c47-11e8-9a36-7bd06cedf058/Pawn.stl

              const job = {
                input: {
                  urn: base64.encode(objectDetails.objectId)
                },
                output: {
                  formats: [
                    {
                      type: "obj"
                    }
                  ]
                }
              };
              derivativesApi
                .translate(job, {}, oAuth2TwoLegged, credentials)
                .then(
                  data => {
                    res.send(data);
                  },
                  err => {
                    // it fails here with 400 status error
                    res.send(err);
                  }
                );
            },
            err => {
              res.send(err);
            }
          );

my job object looks like this:

{
  input:{
    urn: 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6ZDYyZGIwOTAtMGM0Ny0xMWU4LTlhMzYtN2JkMDZjZWRmMDU4L1Bhd24uc3Rs'
  },
  output: {
    formats: [
      type: "obj"
    ]
  }
}

the response

{
  statusCode: 400,
  statusMessage: "Bad Request"
}

原文:https://stackoverflow.com/questions/48673157
更新时间:2022-12-04 22:12

最满意答案

如果我理解正确,那么每当对表进行更改并允许检索所做的更改时,您是否希望创建某种审计历史记录?

每当用户例如更新名称字段时,我想保存此更改,以便其他用户可以根据需要还原更改

考虑你的实体Person,它有一个数据库表,如:

Person
id INT
name NVARCHAR
parentId

要保留更改历史记录,您可以在数据库中拥有“人员更改历史记录”表:

PersonCH
RevisionCount INT
id INT
name NVARCHAR 
parentId INT
ChangeDateTime DATETIME
ChangedByUserID INT

为了解释这是如何工作的,让我们来看看你的例子:

让我们添加一个叫约翰的人:

INSERT INTO Person VALUES (100,'John',99);

同时,我们还应该在历史表中添加记录:

INSERT INTO PersonCH (1,100,'John',99,GETDATE(),123);

如果我们改变John的名字,我们再次在历史表中添加一条新记录:

UPDATE Person SET name = 'Jim' WHERE id = 100;
INSERT INTO PersonCH (2,100,'Jim',99,GETDATE(),123);

实际上,上面的INSERT语句将在AFTER INSERT和/或AFTER UPDATE触发器中,因此我们不需要依赖于在我们的应用程序中始终指定它。

因此,我们的历史表现在有一个我们可以看到的人员变化的审计跟踪

SELECT * FROM PersonCH WHERE id = 100 ORDER BY RevisionCount DESC;

If I understand correctly, you want to create some sort of audit history whenever a change is made to a table and allow retrieval of the changes made?

Whenever a user for example updates the name field, I want to save this change, so other users can revert the change, if desired

Consider your entity Person which would have a database table like:

Person
id INT
name NVARCHAR(20)
parentId INT

to keep the change history, you can have a Person Change History table in your database:

PersonCH
RevisionCount INT
id INT
name NVARCHAR 
parentId INT
ChangeDateTime DATETIME
ChangedByUserID INT

To explain how this would work, lets work through your example:

Lets add a person called John:

INSERT INTO Person VALUES (100,'John',99);

At the same time, we should also add a record to our history table:

INSERT INTO PersonCH (1,100,'John',99,GETDATE(),123);

and if we change John's name we again add a new record to the history table:

UPDATE Person SET name = 'Jim' WHERE id = 100;
INSERT INTO PersonCH (2,100,'Jim',99,GETDATE(),123);

In reality, the INSERT statement above would be in an AFTER INSERT and / or AFTER UPDATE trigger so we don't need to rely on always specifying it in our application.

Therefore our history table now has an audit trail of this Person's changes which we can see using

SELECT * FROM PersonCH WHERE id = 100 ORDER BY RevisionCount DESC;

相关问答

更多
  • 强制推送,比如git push origin +master应该有所帮助。 所有远程更改都将丢失。 A forced push such as git push origin +master should help. All remote changes will be lost.
  • 只需创建一个新的根的父项的嫁接提交给没有父(或一个空提交,例如您的存储库的真正根提交)。 例如echo "" > .git/info/grafts 创建移植后,立即生效; 您应该可以看看git log ,看看不必要的旧提交已经消失了: $ echo 4a46bc886318679d8b15e05aea40b83ff6c3bd47 > .git/info/grafts $ git log --decorate | tail --lines=11 commit cb3da2d4d8 ...
  • 如果我理解正确,那么每当对表进行更改并允许检索所做的更改时,您是否希望创建某种审计历史记录? 每当用户例如更新名称字段时,我想保存此更改,以便其他用户可以根据需要还原更改 考虑你的实体Person,它有一个数据库表,如: Person id INT name NVARCHAR parentId 要保留更改历史记录,您可以在数据库中拥有“人员更改历史记录”表: PersonCH RevisionCount INT id INT name NVARCHAR parentId INT ChangeDateTi ...
  • 您可以采取两项措施来加快流程。 首先是为它提供计算能力。 如果您拥有Enterprise Edition和许多内核,则可以通过并行查询显着减少加载时间。 另一件事是避免加载你不想要的记录。 这就是你提到预处理文件的原因。 我不确定你能做多少事情,除非你有权访问Hadoop集群在你的文件上运行一些map-reduce作业(好吧,主要是减少,你发布的结构就像已经映射的那样)。 但还有另一种选择:外部表格。 外部表是在OS文件中具有数据而不是表空间的表。 并且它们可以并行启用(提供您的文件符合特定条件)。 了解更 ...
  • 你是对的,数据库有一种计算这种信息的方法。 Select count(*) as "TicketCount" From requesthx Where techid=3 And status = "open" Group by techid You are correct the database has a way of counting this kind of information. Select count(*) as "TicketCount" From requesthx Where tec ...
  • 当然,这是可能的。 在“文件”选项卡中单击要检查的文件。 双击它或点击CTRL + L 在打开的日志窗口中,现在只显示处理所选文件的提交。 通过它们并比较屏幕底部的更改。 Sure, that's possible. Click onto the file you want to inspect in the Files tab. Double-click it or hit CTRL+L In the opened log window, only commits dealing with your se ...
  • 我认为将MySQL用于用户帐户并使用CouchDB获取已爬网信息没有任何问题。 对于用户,您甚至可以考虑更简单的事情,比如GDBM I don't see anything wrong with using MySQL for users accounts and CouchDB for crawled information. For the users, you might even consider something simpler, like GDBM
  • 笔记本上下文启动了一个Spark应用程序,它将在您的工作完成后继续运行20分钟。 在此期间提交其他作业时,它将使用相同的应用程序并显示在同一历史记录条目中。 因此,您无法在历史记录服务器中跟踪笔记本或Interactive API内核的作业/活动完成情况。 Spark活动在内核日志中生成输出,也许可以提供您正在寻找的信息。 I have taken this up with the spark service engineering team - it is a known issue.
  • 这取决于“所有数据库操作的完整时间点历史记录”的含义。 从备份转发开始,基本备份和所有预写日志(WAL)文件(通常也称为事务日志或xlog)应该允许您恢复到任何时间点 。 但是,为了尽可能缩短恢复时间,最好定期进行新的基本备份。 (许多人每周或每月都这样做,但我听说人们做的事情要少得多。) 这些日志面向数据的物理存储,而不是逻辑语句,因此目前无法确定生成xlog的SQL语句。 因此,如果您正在寻找所发生情况的审计跟踪,那么它目前还不适合。 有一个PostgreSQL开发人员团队致力于逻辑复制,允许更广泛地使 ...

相关文章

更多

最新问答

更多
  • 获取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的基本操作命令。。。