Closed TheOnlyArtz closed 5 years ago
You are using the put_url()
method wrong. Please read the API docs for it.
The way you try to use the convenience methods is very bad coding practice since their signatures are all different. If you read the module documentation, it should be obvious that you are better off using do_method()
instead.
Also, as I have stated before, issues are typically for bugs. Avoid using GitHub issues to ask general questions - use the mailing lists instead.
I don't get the mailing lists can I get relevant info? like, how to subscribe and ask questions from them
You are using the
put_url()
method wrong. Please read the API docs for it.The way you try to use the convenience methods is very bad coding practice since their signatures are all different. If you read the module documentation, it should be obvious that you are better off using
do_method()
instead.Also, as I have stated before, issues are typically for bugs. Avoid using GitHub issues to ask general questions - use the mailing lists instead.
Alright, btw, I don't get how I'm using the PUT wrong, I don't have a file so I'm just sending an empty string and I don't have a connection so I don't send anything at all, I read the documentation and filled the parameters correctly. the query variables are something like
(["topic": "test"])
the headers are something like
(["Authorization": "TOKEN"])
So I don't really get what I'm doing wrong.
Read the documentation! Normally people complain about poor docs in Pike and they are usually right, but in this case there is nothing wrong with the docs.
Compare
.Query put_url(string|Standards.URI url, void|string file, void|mapping(string:int|string|array(string)) query_variables, void|mapping(string:string|array(string)) request_headers, void|Protocols.HTTP.Query con)
to for example
.Query get_url(string|Standards.URI url, void|mapping(string:int|string|array(string)) query_variables, void|mapping(string:string|array(string)) request_headers, void|Protocols.HTTP.Query con)
.
See? The signatures are vastly different. In the first instance query variables are the third argument and in the second case they are the second argument.
Right! and I'm passing the query variables as the 3rd argument! I'm sorry I didn't show you the whole relevant code but it looks like
if (lower_case(method) != "put")
response = Protocols.HTTP[lower_case(method) + "_url"](uri, data, headers);
else
response = Protocols.HTTP[lower_case(method) + "_url"](uri,"", data, headers);
I am passing the query variables as the 3rd argument!
So, whenever PUT is being requested the data (query variables)
will get passed as the 3rd argument
Okay update, I've managed to send put
request successfully, sorry for everything, from now and then I will use the mailing list!
Last: can I call PATCH
method when using do_method
?
Yes, do_method()
is the method you should be using for this type of thing. And it doesn't really care about what verb you use.
Alright, that sounds way better! thank you, checking it out right now.
I'm trying to establish a PUT HTTP request since there's no PATCH (Why there's no patch too? :) )
What may be the cause? I don't think I'm doing anything wrong