Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

同步帐单出现异常 #520

Open
Jalright opened this issue Aug 6, 2021 · 2 comments
Open

同步帐单出现异常 #520

Jalright opened this issue Aug 6, 2021 · 2 comments

Comments

@Jalright
Copy link

Jalright commented Aug 6, 2021

{"error": "[SDK.JsonUnmarshalError] Failed to unmarshal response, but you can get the data via response.GetHttpStatusCode() and response.GetHttpContentString()
caused by:
bssopenapi.QueryBillOverviewResponse.Data: bssopenapi.Data.Items: []bssopenapi.Item: decode slice: expect [ or n, but found {, error found in #10 byte of ...|,"Items":{"Item":[{"|..., bigger context ...|"2021-04","AccountID":"xxxxxxx","Items":{"Item":[{"DeductedByCoupons":0.000000,"RoundDownDi|..."}

版本: github.com/aliyun/alibaba-cloud-sdk-go v1.61.1208

@0xe590b4
Copy link

type Data struct {
            // 这个结构体官方有问题,重新自定义
	Items map[string][]billing.Item `json:"Items" xml:"Items"`
}

type QueryBillOverviewResponse struct {
	RequestId string `json:"RequestId" xml:"RequestId"`
	Success   bool   `json:"Success" xml:"Success"`
	Code      string `json:"Code" xml:"Code"`
	Message   string `json:"Message" xml:"Message"`
	Data      Data   `json:"Data" xml:"Data"`
}

var (
	
	result QueryBillOverviewResponse
)

request := billing.CreateQueryBillOverviewRequest()
request.BillingCycle = billingCycle
request.AcceptFormat = "json"
request.Scheme = "https"
resp, _ := client.billingClt.QueryBillOverview(request)

body := resp.GetHttpContentBytes()

    // 这里自解析结构体太深,忽略错误吧
json.Unmarshal(body, &result)

for _, instance := range result.Data.Items["Item"] {
           // 正常的遍历就OK
    }

    坐等官方更新,我看所有的接口都是有问题的JSON格式

@feeops
Copy link

feeops commented Nov 29, 2021

v1.61.1352有这个问题
v1.61.1311没有这个问题,可以回滚

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants