last day (16 days later) » 

12:29 PM
0
A: Angular Resource PUT Operation with Payload

Erezapp.factory('Request', ['$resource', function ($resource) { var res = $resource('bin/server.fcgi/REST/:resourceName/:ID', {resourceName: "@resourceName", ID: "@ID"}, { get : { method : 'GET' }, put :...

 
Now i take the following: http://localhost/agenda/bin/server.fcgi/REST/:@resourceName/26 its very strange
 
the names have to be equals and if its empty it can be
 
the name resourceName is equal everywhere?
 
yes it should be but as you can see it works you just miss something
 
yeah the query is working now with the following: $resource("bin/server.fcgi/REST/" + ':resourceName/:ID', {resourceName:"@resourceName", ID: '@ID'}, { put : { method : "PUT", params: { ID: '@ID', resourceName:"@resourceName" } } }); However resourceName is also contained in payload and it shouldn't go to server. So take now this error from server : Unknown property: "resourceName" how can we avoid that resourceName is not sent to server as a property ??
 
12:29 PM
make it am empty by defualt like params: {resourceName: "" , ID: "@ID"}, but it can be default, it look like the id the resource name id
 
it is still sent to the server even if i make it empty ..
 
cause it comes before the /id
or make it opposite or make them both with no /
but i dont understand why you need the resource name as url param if it can be empty
if you want to put by id and update all field you dont have to pot it in the url
$resource('bin/server.fcgi/REST/:ID', {ID: '@ID'}, {
put : {method : "PUT", params: { ID: '@ID', resourceName:""}}})
or even you dont need the resource name
put : {method : "PUT", params: {ID: '@ID'}}
 
12:46 PM
Actually i use resourceName to call the same function to retrieve the results of different tables in a REST interface
I tried almost each combinations :(
i swiped id and resourceName and gets "unknown property: resourcaName"
 
i dont get you
you use the resource name to call the same function where? on the rest? why ?
 
for example: to fetch users REST/USER and to fetch REST/GRADES... REST/:resourceName is just a variable for both of them
 
and if its empty?
 
its never empty .. it is fired only when the results are needed from a table. I give then just the name of that table and the possible parameters. thats it
 
and you have the both url in the rest?
in the server?
 
12:57 PM
yes
 
you trying to call them together? like request.all?
and the both rset end point accept the same params?
 
yes precisely
 
i have edited my answer
can you copy my factory and send the same params names and give me the results or the error?
 
what did you change precisely? I couldn't find any change :/
 
1:14 PM
i did remove some } had too many
but wait a minute i will edit
again
 
okey... it gives already the same error "resourcaName is not property"...
 
edited please copy and call it and tell me the results
 
okey i try it directly
 
copy the error if its an error
 
1:29 PM
nope .. the result is the same
 
whats the full error
 
thank you for your help anyway
 
?
welcome but its wired i do resource all the time and never happened to me
 
oh i toke that error from cache
i'm trying your code but there are syntax errors
i'm working on it now
 
ok haha
 
1:35 PM
but that return {}); ? :D
 
empty object? what should be returned?
 
it would then return always {} i think ... no?
 
if you return something from the server it will return the server output
 
okey
now something different;
{ "success" : false, "data" : [], "message" : "Invalid input: Unknown streamer type: \"\"." }
i have noo any idea what it means
 
well the url works? you send the right params?
 
1:40 PM
url is good
but this time no any payload
thats the reason of this error i think
 
ok so the question has been answered
now lets focus on the output from server
what the server should get
the params match to server params ?
 
for a PUT operation, u should have at least ID and one other parameter
in this case there is nothing i see
 
in your sever? body ?
 
in my request
there should be info in payload in the request
 
console log that and see the params and see that you dont send empty params
 
1:57 PM
yeah there is no payload... if it was, we could see it as the last in this view
 
i dont know this error but you we can see the params sent so its something in the server
maybe there " char that you send without notice
 
i will check it tomorrow further
and i will let you know when its fixed
i didnt understand that too
its so strange
 
2:13 PM
yeah but if this question answered confirm and make another with the error maybe more ppl can help you
good luck let me know
 
i will man! thanks a lot for your effort!
 

  last day (16 days later) »