retrofit2

Azure Cosmos DB - bad request - http:400

我是研究僧i 提交于 2019-12-13 18:13:39
问题 Greetings my fellow developers, It is already 3 days I'm struggling with a connection to the Cosmos DB without success. I'm using retrofit as my REST client and GsonConverterFactory for serialization/deserialization. Current status is that I get HTTP:400 (bad request) from Cosmos DB REST API. I have tried to adopt the authentication header generation from this SO answer So here is my code (this unit test is runnable from your development environment. please see gradle.build lines to run it in

java.io.EOFException: End of input at line 1 column 1

强颜欢笑 提交于 2019-12-13 16:09:34
问题 My Retrofit should recieve a List of Bookmarks, and everything worked while I was using WAMP server. When I changed server to external (nothing else changed, just ip address of the server and retrieving of everything else works) I have an error: java.io.EOFException: End of input at line 1 column 1 at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1407) at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:553) at com.google.gson.stream.JsonReader.peek(JsonReader

How do I rename a file to google drive rest api? Retrofit2

半城伤御伤魂 提交于 2019-12-13 14:46:14
问题 In the Google documentation about it is not written, I use retrofit 2. Help. Write what request should be sent and what parameters to transmit interface: @PATCH("drive/v3/files/{fileId}") @Multipart Call<ResponseBody> renameFileGoogle( @Path("fileId")String fileId, @Part MultipartBody.Part metaPart ); call metod: public void renameMetod(String id, String title) { String content = "{\"name\": \"" + title + "\"}"; MediaType contentType = MediaType.parse("application/json; charset=UTF-8");

Retrofit 2 - delayed response

被刻印的时光 ゝ 提交于 2019-12-13 13:35:34
问题 I have a problem with retrofit 2. I'm sending some data to Microsoft EAS server but a response is received after 20 sec. Why I know that this is a retrofit problem? Because without retrofit it is working correctly. my logs: D/OkHttp: --> POST https://{my_host}/Microsoft-Server-ActiveSync?Cmd=Provision&User={myuser}&DeviceId=837bc6c5690b40b98ab55f7a2231e50c&DeviceType={mydevicetype} http/1.1 D/OkHttp: Content-Type: application/vnd.ms-sync.wbxml D/OkHttp: Content-Length: 456 D/OkHttp:

Regulate network calls in SyncAdapter onPerformSync

房东的猫 提交于 2019-12-13 13:27:03
问题 I m sending several retrofit calls via SyncAdapter onPerformSync and I m trying to regulate http calls by sending out via a try/catch sleep statement. However, this is blocking the UI and will be not responsive only after all calls are done. What is a better way to regulate network calls (with a sleep timer) in background in onPerformSync without blocking UI? @Override public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult

how to fix this error java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ [duplicate]

瘦欲@ 提交于 2019-12-13 10:19:23
问题 This question already has answers here : Why does Gson fromJson throw a JsonSyntaxException: Expected BEGIN_OBJECT but was BEGIN_ARRAY? (2 answers) Closed 3 years ago . I'm implementing a restful client using Android. I have API URL, token, etc. I implement this application using Retrofit 2 library, all are correct. But the JSON values do not display properly. I've tried several ways to solved this problem but can't find any correct solution for this. This is my code: JSON string {"deposits":

Retrofit 2 response body is empty or Model class is wrong. Cannot get JSON data it gives an Exception: Expected BEGIN_ARRAY but was BEGIN_OBJECT

纵然是瞬间 提交于 2019-12-13 09:48:28
问题 This is my JSON response: { status: "ok", count: 25, categories: [ { id: 60, slug: "3d", title: "3D", description: "", parent: 70, post_count: 86 }, { id: 2, slug: "action-adventure", title: "Action/Adventure", description: "", parent: 70, post_count: 980 }, { id: 61, slug: "bollywood", title: "Bollywood", description: "", parent: 0, post_count: 747 }, { id: 3, slug: "comedy", title: "Comedy", description: "", parent: 70, post_count: 790 }, { id: 14, slug: "documentaries", title: "Documentary

Retrofit2: Sending POST request with String request

浪尽此生 提交于 2019-12-13 09:05:19
问题 Hi I am new to android and now I am using Retrofit for integrating the web services. I am not understanding how to send parameters to the server using Retrofit POST request. Please help me. Thanks. MainActivity:- String url = "XXXXXXXXX/"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Retrofit retrofit = new Retrofit.Builder().baseUrl(url). addConverterFactory(GsonConverterFactory.create()).build();

Issue with Special Characters in Retrofit 2 encoding

和自甴很熟 提交于 2019-12-13 08:11:10
问题 So I'm looking to make a request to our api to log in a user, however there is a section that gets encoded in the Retrofit 2 method even though its set as encoded = true . The base url is https://testapi.test.ie The parameter I pass as the serverext is mdc.php?action= However even after setting encoded = true the resulting request body is: https://testapi.test.ie/mdc.php%3Faction=login_user&ts=1482924232742 where I require it to be: https://testapi.test.ie/mdc.php?action=login_user&ts

Upload image into server using retrofit

梦想的初衷 提交于 2019-12-13 08:02:46
问题 I want to upload image/file to server using its uri using below code try { String descriptionString = "Sample description"; RequestBody description = RequestBody.create(MultipartBody.FORM, descriptionString); File file = new File(path); String extension = MimeTypeMap.getFileExtensionFromUrl(uri.toString()); if (extension != null) { String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); RequestBody requestFile = RequestBody.create(MediaType.parse(type), file);