How do I send a JSON string in a POST request in Go

后端 未结 4 530
执笔经年
执笔经年 2020-11-30 16:17

I tried working with Apiary and made a universal template to send JSON to mock server and have this code:

package main

import (
    \"encoding/json\"
    \"         


        
4条回答
  •  -上瘾入骨i
    2020-11-30 16:42

    you can just use post to post your json.

    values := map[string]string{"username": username, "password": password}
    
    jsonValue, _ := json.Marshal(values)
    
    resp, err := http.Post(authAuthenticatorUrl, "application/json", bytes.NewBuffer(jsonValue))
    

提交回复
热议问题