working api post
parent
13b2b5df98
commit
2417954770
@ -0,0 +1,49 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
// "strings"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
const (
|
||||
ApiEndpoint = "https://hodlhodl.com/api/v1"
|
||||
TestApiEndpoint = "https://hhtestnet.com/api/v1"
|
||||
ApiKey = "***REMOVED***"
|
||||
)
|
||||
|
||||
|
||||
type response struct {
|
||||
Status string `json:"status"`
|
||||
ExchangeRateProviders []struct {
|
||||
Name string `json:"name"`
|
||||
CurrencyCodes []string `json:"currency_codes"`
|
||||
} `json:"exchange_rate_providers"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("hello world")
|
||||
//body:= strings.NewReader(' -X POST -H "Authorization: Bearer ***REMOVED***" -H "Content-Type: application/json"`)
|
||||
req, err := http.NewRequest("POST", TestApiEndpoint + "/notifications/read", nil)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
req.Header.Add("Authorization", "Bearer " + ApiKey)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err!= nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
fmt.Println(resp.Status)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println(string(body))
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
}
|
Loading…
Reference in New Issue