Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialZubeyr Aciksari
21,074 PointsI am stuck in here, can someone please help me? Thanks!
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_movie); OkHttpClient Client= new OkHttpClient(); Request request=new RequestBuilder().url(apiUrl).build();
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MovieActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_movie);
OkHttpClient Client= new OkHttpClient();
Request request=new RequestBuilder().url(apiUrl).build();
// Get some movie information!
String apiUrl = "http://api.rottentomatoes.com/api/public/v1.0/movies.json?apikey=xyz&q=hobbit";
}
}
4 Answers
Patrick Corrigan
5,739 PointsYou're actually very close to the correct answer. There are just two things you need to change.
The line:
Request request=new RequestBuilder().url(apiUrl).build();
Should be
Request request=new Request.Builder().url(apiUrl).build();
This is because Builder() is a static method of the Request class.
The second change is that you need to move that line so that it's below the line that defines "apiUrl". Where you have it now it won't know what that variable is. If you make those two changes you should be able to pass the test.
eeeee eeee
16,283 PointsWow if anyone have problem with it even if you are pretty sure you did it correctly I tell you how it passed for me. As a parameter for the url() instead of apiUrl I copy pasted the url itself "http://api.rottentomatoes.com/api/public/v1.0/movies.json?apikey=xyz&q=hobbit" (this is different for you, don't copy it from here)
and this is how it worked for me, interesting.
Mitchelle Musarurwa
4,498 PointsI cant figure it out where this line shld go........im stuck
Zubeyr Aciksari
21,074 PointsHere is the questions: Next we need to create and build a Request. Declare a new Request variable, and then set it by chaining a few methods together. First use new Request.Builder(), then chain the url() method using apiUrl as the parameter. Then chain build() to finish.
Zubeyr Aciksari
21,074 PointsThanks Patrick, it worked :)
eeeee eeee
16,283 Pointseeeee eeee
16,283 PointsI even copy pasted the line man it still doesn't work, don't get it