Re: Re: cURL / HTTPS PUT Request
The response includes a resp.Body which can be directly used via json.NewDecoder(resp.Body).Decode(&obj)
Another question.. I got a json as a response, but its not byte-encoded could i make it byte-encoded and decode it via unmarshal?
Am Dienstag, 1. Mai 2012 00:50:51 UTC+2 schrieb Christian Schmitt:Oh my god.. No... Sorry dude..it works know -.- missed the string.Reader() my solution was so close, but i overreaded you and the string reader...solutions can be so easy..
Am Montag, 30. April 2012 23:56:35 UTC+2 schrieb Kyle Lemons:Did you read my post?On Mon, Apr 30, 2012 at 2:35 PM, Christian Schmitt <c.schmitt-7OAYUylD4M3gyKjI7qutAw@public.gmane.org> wrote:req.FormValue("status=SHUTDOWN") didn't work cause it will be ignored. but i don't know how to form a io.Reader with a string like "status=SHUTDOWN" or a json string.
Am Montag, 30. April 2012 23:28:45 UTC+2 schrieb Christian Schmitt:Yeah I got this already:
package mainimport "fmt"import "net/http"import "io/ioutil"
func main() {client := &http.Client{}req, _ := http.NewRequest("PUT", "https://api.jiffybox.de/HASH/v1.0/jiffyBoxes/ID", nil)req.FormValue := "status=SHUTDOWN"resp, _ := client.Do(req)out, _ := ioutil.ReadAll(resp.Body)resp.Body.Close()fmt.Printf("%s", out)}Still I didn't need to know how to send the Data like "status=SHUTDOWN" or in json {"key1":value1} I only know how to make a request not how to send data.. that is my problem i know i need something with io.Reader but don't know how to make it correctly
Am Montag, 30. April 2012 22:53:03 UTC+2 schrieb Volker Dobler:
On Apr 30, 10:27 pm, Christian Schmitt <c.schm... <at> briefdomain.de>
wrote:
> I searched the HTTP Library but I didn't find anything to make a HTTPS
> Request, so how could I do it?
Did you try something like (untested pseudocode):
request, err := http.NewRequest("PUT", url, body)
response, err := http.DefaultClient.Do(request)
?
V
RSS Feed