收到“错误":“内部错误";在邮递员上并且遇到错误无法从START_OBJECT令牌中反序列化java.util.ArrayList的实例 [英] Getting "error": "Internal Error" on Postman and getting error Can not deserialize instance of java.util.ArrayList out of START_OBJECT token

查看:124
本文介绍了收到“错误":“内部错误";在邮递员上并且遇到错误无法从START_OBJECT令牌中反序列化java.util.ArrayList的实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当Postman遇到Softlayer剩余URL时,出现以下错误:

While hitting below Softlayer rest url from Postman getting error:

内部错误"

"Internal Error"

当使用spring restTemplate从Java代码中访问相同的rest url时,出现错误

And when hitting the same rest url from java code using spring restTemplate getting error as

无法反序列化java.util.ArrayList的实例 START_OBJECT令牌.

Can not deserialize instance of java.util.ArrayList out of START_OBJECT token.

https://api.softlayer.com/rest/v3/SoftLayer_Account/<Account-ID>/getInvoices?objectFilter={"invoices":{"createDate":{"operation":"betweenDate","options":[{"name":"startDate","value":["03/25/2017 00:00:00"]},{"name":"endDate","value": ["04/24/2017 23:59:59"]}]},"typeCode":{"operation":"RECURRING"}}}&objectMask=mask[id,items[id,recurringFee,recurringTaxAmount,oneTimeFee,oneTimeTaxAmount,description,hostName,domainName,hourlyRecurringFee,laborFee,laborTaxAmount,setupFee,setupTaxAmount,category[name],location[longName],billingItem[id,activeFlag,hourlyFlag,allowCancellationFlag,cancellationDate,orderItem[id,order[id,userRecord[username]]]]]]

推荐答案

当发票中没有很多物品时,您发布的REST URL可以使用.您收到 内部错误" ,因为内部某些发票正在返回错误 "已耗尽402653184字节的内存容量(尝试分配131072字节) " ,这是在添加时

The REST URL you posted is working when the invoices don't have a lot of items. You are getting "Internal Error" because internally some invoices are returning the error "Allowed memory size of 402653184 bytes exhausted (tried to allocate 131072 bytes)", this when is added

orderItem[id,order[id,userRecord[username]]]

我只有一张发票也遇到了同样的错误,就我的发票而言,有1500多个项目,这是很多项目.

I got the same error with just one invoice, on my case the invoice have more than 1500 items, this is a lot of items.

您的遮罩深度很大,因此要检索很多数据,因此Ruber建议在此处

Your mask is very big in depth and there are a lot of data to retrieve, for that reason Ruber recommends here Softlayer rest call giving multiple entries for invoice in json response when object filter is applied to relational properties use some programming language in order to retrieve all data you required:

基本上,您需要执行以下操作:

Basically you need to do the following:

第1步: 根据您的要求,使用 SoftLayer_Account :: getInvoices 获取所有发票像这样:

Step 1: Get all invoices by using SoftLayer_Account::getInvoices, based on you requirements it should be something like this:

https://api.softlayer.com/rest/v3/SoftLayer_Account/getInvoices?objectFilter={"invoices":{"createDate":{"operation":"betweenDate","options":[{"name":"startDate","value":["03/25/2017 00:00:00"]},{"name":"endDate","value": ["04/24/2017 23:59:59"]}]},"typeCode":{"operation":"RECURRING"}}}&objectMask=mask[id,createDate]

这将返回所有发票的ID,在接下来的步骤中您将需要它

This will return the ID of all invoices, you will need this in the following step

第2步: 对于每个检索到的发票,请使用方法 SoftLayer_Billing_Invoice :: getItems ,使用resultLimits和您的遮罩如下.

Step 2: For each retrieved invoice use the method SoftLayer_Billing_Invoice::getItems, use resultLimits and your mask as following.

https://api.softlayer.com/rest/v3/SoftLayer_Billing_Invoice/[invoiceId]/getItems?resultLimit=100,0&objectMask=mask[id,recurringFee,recurringTaxAmount,oneTimeFee,oneTimeTaxAmount,description,hostName,domainName,hourlyRecurringFee,laborFee,laborTaxAmount,setupFee,setupTaxAmount,category[name],location[longName],billingItem[id,activeFlag,hourlyFlag,allowCancellationFlag,cancellationDate,orderItem[id,order[id,userRecord[id,username]]]]]

通过在步骤1中检索的每个ID更改 [invoiceId] .

Change [invoiceId] by each ID you retrieved in the step 1.

在这种情况下,您需要使用循环,第一个循环调用 SoftLayer_Billing_Invoice ::每个发票的getItems 和第二个循环以100为单位检索项目100.(代替100,您可以在resultLimit参数中设置另一个值)

On this case you need to use loops, the first loop to call SoftLayer_Billing_Invoice::getItems for each invoice and the second loop to retrieve items 100 by 100.(Instead of 100 you can set another value in resultLimit parameter)

如果设置 resultLimit = 100,1 ,它将返回101到200之间的所有项目.我建议您查看

If you set resultLimit=100,1 it will return all items between 101 to 200. I suggest to review https://sldn.softlayer.com/article/using-result-limits-softlayer-api

我建议使用 Python 转到 Ruby 等.您可以在此处

I recommend to use languajes like Python, Java, Go, Ruby, etc. You can see the list here https://sldn.softlayer.com/article/softlayer-api-overview.

注意:不幸的是,SoftLayer Java API不支持对象过滤器功能.

Note: Unfortunately the object-filters feature is not supported by SoftLayer Java API.

希望这对您有所帮助.

此致

这篇关于收到“错误":“内部错误";在邮递员上并且遇到错误无法从START_OBJECT令牌中反序列化java.util.ArrayList的实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆