rest - Passing params to POST API -



rest - Passing params to POST API -

i new designing rest apis. have trying create next apis online game play

get domain/api/games // homecoming games post domain/api/games // create new game on behalf of current user

now issue when seek create game using post, want userid sent api. not sure how this. note have api details of individual game, like

get domain/api/games/{gameid}

so cannot pass userid post domain/api/games/{useid} conflict above api. how pass usedid post. don't want utilize query params. suggestions design great.

when making post service, parameters communicate known body params, don't go on query string.

different technologies have different apis interacting post params, underlying theory same, , described w3c http standard

http://www.w3.org/protocols/rfc2616/rfc2616-sec9.html

the specifics of how utilize post params vary depending on language , technology you're using. example, if using jquery, there couple different ways it, with $.post('url', data, callback) method or $.ajax(...) option.

http://api.jquery.com/jquery.post/

http://api.jquery.com/jquery.ajax/

when reading post params on server, you'll access them using some sort of request object, store parameters in memory access. highly dependent of language , framework you're using, here links mutual ones:

nodejs/express: http://expressjs.com/4x/api.html#request

php: http://php.net/manual/en/reserved.variables.post.php

asp.net: http://msdn.microsoft.com/en-us/library/system.web.httprequest.params(v=vs.110).aspx

java/spring: https://spring.io/guides/gs/handling-form-submission/

api rest design

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -