cloudstack-go icon indicating copy to clipboard operation
cloudstack-go copied to clipboard

Error to decode RegisterUserKeys

Open lucasdk3 opened this issue 1 year ago • 1 comments

image Hi, i have a error when decode RegisterUserKeys, because response is a string not a map {"status-code":500,"error-code":"CloudstackApiError","details":"json: cannot unmarshal string into Go value of type cloudstack.RegisterUserKeysResponse"} image

lucasdk3 avatar Dec 20 '24 20:12 lucasdk3

@lucasdk3 I wasn't able to reproduce this issue. I added some test data - https://github.com/apache/cloudstack-go/pull/99/files and tried running the RegisterUserKeys test using:

/sb/cloudstack-go$ /usr/local/go/bin/go test -timeout 30s -run ^TestUserService$/^RegisterUserKeys$ github.com/apache/cloudstack-go/v2/test
ok  	github.com/apache/cloudstack-go/v2/test	0.007s

And it successfully ran.

Just to validate if the test was actually being run, I tried to change the response structure to :

  "registerUserKeys": {
    "registeruserkeysresponse": {
        "apikey": "hNfJi2dO5kwD6gTtYoifqu_4CSI3FcTtxc4MydW24PdJalv8mfTGsf425twAdLrIKX5IewfqIfYDEumO6-yRaw",
        "secretkey": "zV8kAYlyY4H-rEDO-Ot-VVPjKteVcU4haQcdRarte9wuOUhko3uzcnnFqNii8xifcpbe0eWR6IHAXjVGB2m1Hw"
    } 
  }

And on re-running the test it failed - indicating that the test runs fine:

/sb/cloudstack-go$ /usr/local/go/bin/go test -timeout 30s -run ^TestUserService$/^RegisterUserKeys$ github.com/apache/cloudstack-go/v2/test
--- FAIL: TestUserService (0.00s)
    --- FAIL: TestUserService/RegisterUserKeys (0.00s)
        UserService_test.go:180: json: cannot unmarshal string into Go value of type cloudstack.RegisterUserKeysResponse
FAIL
FAIL	github.com/apache/cloudstack-go/v2/test	0.007s
FAIL

Can you please let us know if there's anything different that needs to be done.

Pearl1594 avatar Dec 31 '24 11:12 Pearl1594