Error: HTTP method GET is not supported by this URL

420 views
Skip to first unread message

Vivek Kumar

unread,
Mar 21, 2017, 8:12:06 PM3/21/17
to Google Cloud Endpoints
my URL: https://visionapi-153614.appspot.com/_ah/api/instaSmartApi/v1


not sure why.

java looks lik

package photography.viks.ig;


import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.ApiMethod;
import com.google.api.server.spi.config.ApiNamespace;
import com.google.api.server.spi.config.Named;
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;


@Api(name = "instaSmartApi",
version = "v1",
   scopes = {Constants.EMAIL_SCOPE},
   clientIds = {Constants.WEB_CLIENT_ID, Constants.ANDROID_CLIENT_ID, Constants.IOS_CLIENT_ID},
    namespace = @ApiNamespace(ownerDomain = "viks.photography",
         ownerName = "viks.photography",
         packagePath="")
)
public class InstaSmartService {
private static final Logger log = Logger.getLogger(InstaSmartService.class.getName());
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
@ApiMethod(name = "uploadImage")
public ArrayList<String> uploadImage(@Named("keyword") String keyword) throws Exception{
log.setLevel(Level.INFO);
ArrayList<String> ar = new ArrayList<String>();
ar.add("Hey " + keyword);
   return ar;
}
}



and web.xml

<?xml version="1.0" encoding="utf-8"?>

<web-app xmlns="http://java.sun.com/xml/ns/javaee"

         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

         xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 

         version="2.5">

  <servlet>

        <servlet-name>SystemServiceServlet</servlet-name>

        <servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>

        <init-param>

            <param-name>services</param-name>

            <param-value>photography.viks.ig.InstaSmartService</param-value>

        </init-param>

    </servlet>

    <servlet-mapping>

        <servlet-name>SystemServiceServlet</servlet-name>

        <url-pattern>/_ah/api/*</url-pattern>

    </servlet-mapping>

    

  <welcome-file-list>

    <welcome-file>index.html</welcome-file>

  </welcome-file-list>

</web-app>

marcus....@apegroup.com

unread,
Mar 22, 2017, 11:35:05 AM3/22/17
to Google Cloud Endpoints
This is because the method name is used to figure out the appropriate HTTP method, unless explicitly given. 

Just change your annotation to include the proper method:
@ApiMethod(name = "uploadImage", httpMethod = HttpMethod.GET)

Reply all
Reply to author
Forward
0 new messages