input-output-hk / cardano-sl

Cryptographic currency implementing Ouroboros PoS protocol
Apache License 2.0
3.76k stars 629 forks source link

API v1 error trying to create address #3858

Open ghost opened 5 years ago

ghost commented 5 years ago

Hi, when I go to try and create a new address for my wallet using CURL and API v1, I get this error:

Array ( [status] => error [diagnostic] => Array ( [validationError] => Error in $: When parsing the constructor NewAddress of type Cardano.Wallet.API.V1.Types.NewAddress expected Object but got Array. ) [message] => JSONValidationFailed )

and it seems like no matter what I do, nothing seems to work. has anybody else had this problem or maybe could shed some light on whats going wrong?

thanks!

PS: Other CURL request to the API return the right and proper JSON results as shown in the documentation.

baldhadhaval08 commented 5 years ago

Hello, I'm getting same error when i tried to create a new address for my wallet using php-wrapper library (https://github.com/zech001/Cardano-Api-PHP-Wrapper).

array(3) { ["status"]=> string(5) "error" ["diagnostic"]=> array(1) { ["validationError"]=> string(129) "Error in $: When parsing the constructor NewAddress of type Cardano.Wallet.API.V1.Types.NewAddress expected Object but got Array." } ["message"]=> string(20) "JSONValidationFailed" } Can anyone please guide here.

Thanks.

ghost commented 5 years ago

@baldhadhaval08 hey, here is a totally lame and half ass fix for that problem, but its going to get you a different error (see my post about not enough input).

copy the "post" function into a new function, lets call it "altPost" for good measure. Then simply change this line:

curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postFields));

to this:

curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);

you can probably do something like just change the way you encode the input or something to not need to make this change, but im lazy and havent bothered to work on that yet. and then the functions that give you an error about objects or arrays, use the altPost instead and it will "work."