开发者社区> 问答> 正文

调用短信API时报 Server response has a bad format type: R

package com.cummins.aliyun.message.message;

import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;

public class SendMessage {
	
	public static void main(String[] args) {
		String accessKey_ID = "xxx";
		String AccessKey_Secret = "xxx";
		DefaultProfile profile = DefaultProfile.getProfile("cn-qingdao", accessKey_ID, AccessKey_Secret);
        IAcsClient client = new DefaultAcsClient(profile);
        
        CommonRequest request = new CommonRequest();
        request.setSysMethod(MethodType.POST);//调用方式
        //request.setSysDomain("dysmsapi.aliyuncs.com");
        request.setSysDomain("106.11.45.35");
        request.setSysVersion("2017-05-25");//版本
        request.setSysAction("SendSms");//系统规定参数
        request.putQueryParameter("PhoneNumbers", "xxx");
        request.putQueryParameter("SignName", "xxx");
        request.putQueryParameter("TemplateCode", "xxx"); //通用通知模板
        request.putQueryParameter("TemplateParam", "{\"code\":\"message_test_cummins\"}");
        try {
        	System.out.println("request:"+request);
            CommonResponse resp = client.getCommonResponse(request);
            System.out.println(resp);
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
	}
	
}

Exception in thread "main" java.lang.IllegalStateException: Server response has a bad format type: RAW at com.aliyuncs.reader.ReaderFactory.createInstance(ReaderFactory.java:16) at com.aliyuncs.DefaultAcsClient.readError(DefaultAcsClient.java:420) at com.aliyuncs.DefaultAcsClient.getCommonResponse(DefaultAcsClient.java:174) at com.cummins.aliyun.message.message.SendMessage.main(SendMessage.java:32)

展开
收起
vywtatirmdmzu 2021-05-18 10:52:08 1618 0
1 条回答
写回答
取消 提交回答
问答分类:
API
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Spring Boot2.0实战Redis分布式缓存 立即下载
CUDA MATH API 立即下载
API PLAYBOOK 立即下载