Closed IanTDuncan closed 3 months ago
This issue details the connectUser method/class used by Spoonacular to add and delete meal plan related items from their Spoonacular account.
Expected Behavior: Compile correctly and returns user info Actual Behavior: Getting an error 200, something wrong with the user info being supplied
Retrofit Interface
@POST("/users/connect") Call<ConnectUser200Response> connectUser(@Body Object body);
ConnectUser Test Class
package com.example.tester; import com.spoonacular.client.ApiClient; import com.spoonacular.client.auth.ApiKeyAuth; import com.spoonacular.client.model.ConnectUser200Response; import okhttp3.OkHttpClient; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; public class ConnectUser { public static void main(String[] args) { ApiClient defaultClient = com.spoonacular.client.Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.spoonacular.com"); // Configure API key authorization: apiKeyScheme ApiKeyAuth apiKeyScheme = (ApiKeyAuth) defaultClient.getAuthentication("apiKeyScheme"); apiKeyScheme.setApiKey("faadc412663942a8909197924745241d"); // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //apiKeyScheme.setApiKeyPrefix("Token"); Retrofit retrofit = new Retrofit.Builder() .baseUrl("https://api.spoonacular.com") .addConverterFactory(GsonConverterFactory.create()) .build(); MealPlanningService service = retrofit.create(MealPlanningService.class); String requestBody = "{" + "\"email\": \"ianduncan464@gmail.com\"" + "}"; Call<ConnectUser200Response> call = service.connectUser(requestBody); call.enqueue(new Callback<ConnectUser200Response>() { @Override public void onResponse(Call<ConnectUser200Response> call, Response<ConnectUser200Response> response) { if (response.isSuccessful()) { ConnectUser200Response result = response.body(); if (result != null) { System.out.println(result); } else { System.err.println("Response body is null"); } } else { System.err.println("Request failed with code: " + response.code()); } } @Override public void onFailure(Call<ConnectUser200Response> call, Throwable t) { System.err.println("Request failed: " + t.getMessage()); t.printStackTrace(); } }); } }
Operating System: Windows 11 Kotlin Version: 1.5.21 Android Studio Iguana 2023.2.1 Android Gradle Plugin Version: 8.3.0 Gradle Version: 8.4
Closing this issue as we have no need for it
API - Spoonacular - ConnectUser
Description:
This issue details the connectUser method/class used by Spoonacular to add and delete meal plan related items from their Spoonacular account.
Steps To Reproduce:
Expected Vs. Actual Behavior:
Expected Behavior: Compile correctly and returns user info Actual Behavior: Getting an error 200, something wrong with the user info being supplied
Code Snippets:
Retrofit Interface
ConnectUser Test Class
Environment Details:
Operating System: Windows 11 Kotlin Version: 1.5.21 Android Studio Iguana 2023.2.1 Android Gradle Plugin Version: 8.3.0 Gradle Version: 8.4
Current Status:
IN-PROGRESS