Hi,
I try manipulate issue entries from my sample Java application. I can
read issue list from http://code.google.com/p/EXAMPLE-PROJECT/issues/csv
or issue details (http://code.google.com/p/EXAMPLE-PROJECT/issues/
detail?id=1). Read issues work for me good.
But I try add new issue. I authenticate to google acount by
ClientLogin:

    URL url = new URL("https://www.google.com/accounts/ClientLogin";);
    HttpURLConnection urlConnection = (HttpURLConnection)
url.openConnection();
    urlConnection.setRequestMethod("POST");
    urlConnection.setDoInput(true);
    urlConnection.setDoOutput(true);
    urlConnection.setUseCaches(false);
    urlConnection.setRequestProperty("Content-Type","application/x-www-
form-urlencoded");

    StringBuilder content = new StringBuilder();
    content.append("Email=").append(URLEncoder.encode(EMAIL,
"UTF-8"));
    content.append("&Passwd=").append(URLEncoder.encode(PASSWORD,
"UTF-8"));
    content.append("&service=").append(URLEncoder.encode("code",
"UTF-8"));
    content.append("&source=").append(URLEncoder.encode("mySampleApp",
"UTF-8"));

    OutputStream outputStream = urlConnection.getOutputStream();
    outputStream.write(content.toString().getBytes("UTF-8"));
    outputStream.close();

I receive Auth token and try send new POST request to fill new issue:

    URL url = new URL("http://code.google.com/p/EXAMPLE-PROJECT/issues/
entry");
    HttpURLConnection urlConnection = (HttpURLConnection)
url.openConnection();
    urlConnection.setRequestMethod("POST");
    urlConnection.setDoInput(true);
    urlConnection.setDoOutput(true);
    urlConnection.setUseCaches(false);
    urlConnection.setRequestProperty("Content-Type", "application/x-
www-form-urlencoded");
    urlConnection.setRequestProperty("Authorization", "GoogleLogin
auth=" + token);

    StringBuilder content = new StringBuilder();
    content.append("projectname=").append(URLEncoder.encode("EXAMPLE-
PROJECT", "UTF-8"));
    content.append("&summary=").append(URLEncoder.encode("summary
entry", "UTF-8"));
    content.append("&comment=").append(URLEncoder.encode("comment
entry", "UTF-8"));
    content.append("&status=").append(URLEncoder.encode("New",
"UTF-8"));
    content.append("&owner=").append(URLEncoder.encode("laj",
"UTF-8"));
    OutputStream outputStream = urlConnection.getOutputStream();
    outputStream.write(content.toString().getBytes("UTF-8"));

But always I get response (login to google acount):

    <HEAD>
    <TITLE>Moved Temporarily</TITLE>
    </HEAD>
    <BODY BGCOLOR="#FFFFFF" TEXT="#000000">
    <H1>Moved Temporarily</H1>
    The document has moved <A HREF="https://www.google.com/accounts/
Login?continue=http%3A%2F%2Fcode.google.com%2Fp%2FEXAMPLE-PROJECT
%2Fissues%2Fentry">here</A>.
    </BODY>
</HTML>

And my question: is it possible to add new issue from Java application
by build HttpURLConnection as I describe above?

--
Regards
Marek Kliś

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Hosting at Google Code" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-code-hosting?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to