我使用httpwebrequest在c#中使用HTTP PUT调用new DownloadImageFromUrlTask().execute(imagePath);
//add glide dependency in app gradle file
compile 'com.github.bumptech.glide:glide:3.7.0'
public class DownloadImageFromUrlTask extends AsyncTask<String, Void, Bitmap> {
String downloadPath = "";
@Override
protected Bitmap doInBackground(String... args) {
try {
downloadPath = args[0];
return BitmapFactory.decodeStream((InputStream) new URL(downloadPath).getContent());
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Bitmap bitmap) {
if (bitmap != null) {
String photoFileName = downloadPath.substring(downloadPath.lastIndexOf('/') + 1);
String root_Path = Environment.getExternalStorageDirectory().toString();
String saveImagePath = root_Path + "/" + photoFileName;
saveBitmapToJPEGFile(MainActivity.this, bitmap, new File(saveImagePath), 900);
loadImageWithGlide(MainActivity.this, myImageView, saveImagePath);
} else {
myImageView.setImageResource(R.drawable.default_photo);
}
}
}
public static Boolean saveBitmapToJPEGFile(Context ctx, Bitmap theTempBitmap, File theTargetFile, int i) {
Boolean result = true;
if (theTempBitmap != null) {
FileOutputStream out = null;
try {
out = new FileOutputStream(theTargetFile);
theTempBitmap.compress(Bitmap.CompressFormat.JPEG, CommonUtils.JPEG_COMPRESION_RATIO_DEFAULT, out); //kdfsJpegCompressionRatio
} catch (FileNotFoundException e) {
result = false;
e.printStackTrace();
}
if (out != null) {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} else {
result = false;
}
return result;
}
public static void loadImageWithGlide(Context theCtx, ImageView theImageView, String theUrl) {
Glide.with(theCtx)
.load(theUrl)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
.into(theImageView);
}
,但收到400个错误请求,请帮助解决这个问题。
答案 0 :(得分:1)
有两种获取多个信封状态的方法:
使用GET Call,
GET / RESTAPI / V2 /账户/ {帐户ID} /信封/状态?envelope_ids = 39eddd06-0288-4288-91a1-dbe79c732524, 5b54c5dd-4c51-4bc1-8251-6e448de34fd4,8f77680d-90fa-4508-9353-0e0707b9518f
GET调用中没有花括号,只是逗号分隔的envelopeIds
使用PUT Call,
PUT / restapi / v2 / accounts / {accountId} / envelope / status?envelope_ids = request_body
身体应该是 -
{ “envelopeIds”:[ “39eddd06-0288-4288-91a1-dbe79c732524”, “5b54c5dd-4c51-4bc1-8251-6e448de34fd4”,“8f77680d-90fa-4508-9353- 0e0707b9518f”] }
首选PUT调用,因为使用GET对URL中发送的envelopeIds数量有限制,如果达到该限制,可能会出错,而在PUT调用中,所有envelopeIds都会进入有效负载,因此您将没有看到任何错误。