in reply to Re^3: alibaba cloud sms api
in thread alibaba cloud sms api

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^5: alibaba cloud sms api
by holli (Abbot) on Sep 02, 2019 at 16:03 UTC
    InvalidVersionSpecified parameter Version is not valid is quite clearly telling you what's wrong. Or at least where to look. When in doubt, read the code. Your must send the version as part of the query, it's not supposed to be sent as a header.


    holli

    You can lead your users to water, but alas, you cannot drown them.

      thanks for clear response

      but i made changes and send the version through query and removed it from header, but am still getting same error

      my $url = "https://dysmsapi.aliyuncs.com"; my $params = [ RegionId => '1', PhoneNumbers => '4324234', SignName => + 'fghgfhg', TemplateCode => 'fghgfh', api_version => '2018-04-08' ]; my $uri = URI->new(); $uri->query_form(@$params); $urlparam = $uri->as_string; my $req = HTTP::Request->new(POST=>$url); $req->header('Content-Type' => 'application/json; charset=UTF-8'); $req->header('access_key_id' => 'sdsadasd'); $req->header('access_key_secret' => 'asdasdsa');

        If it's any help, the Ruby code posted the following parameters

        AccessKeyId => <accessKeyId>
        Action => SendSms
        Format => JSON
        PhoneNumbers => 7766
        RegionId => default
        SignName => iiuy
        SignatureMethod => HMAC-SHA1
        SignatureNonce => 7e44843695e9a68247e15d3beb018b63
        SignatureVersion => 1.0
        TemplateCode => jkk
        Timestamp => 2019-09-02T16:28:32Z
        Version => 2017-05-25
        Signature => TquzjlguNxK2WdUVVrfm4yYTHZI=
        

        code snippet from rpc_client.rb

        def default_params default_params = { 'Format' => 'JSON', 'SignatureMethod' => 'HMAC-SHA1', 'SignatureNonce' => SecureRandom.hex(16), 'SignatureVersion' => '1.0', 'Timestamp' => Time.now.utc.strftime('%Y-%m-%dT%H:%M:%S +Z'), 'AccessKeyId' => self.access_key_id, 'Version' => self.api_version, } default_params.merge!('SecurityToken' => self.security_token) if + self.security_token

        Also this looks wrong

        $req->header('Content-Type' => 'application/json; charset=UTF-8');

        The content-type in the header was

        application/x-www-form-urlencoded
        poj