// Executes an HTTP Request against the Skuid Pages REST API
Executes an HTTP Request against the Skuid Pages REST API
// Executes an HTTP Request against the Skuid Pages REST API
func (conn *RestConnection) MakeRequest(method string, url string, payload interface{}, params url.Values) (result []byte, err error) {
	endpoint := conn.InstanceUrl + "/services/apexrest" + url
	if params != nil && len(params) != 0 {
		endpoint += "?" + params.Encode()
	}
	var body io.Reader
	if payload != nil {
		jsonBytes, err := json.Marshal(payload)
		if err != nil {
			return nil, err
		}
		body = bytes.NewReader(jsonBytes)
	}
	req, err := http.NewRequest(method, endpoint, body)
	if err != nil {
		return result, err
	}
	req.Header.Add("Authorization", "Bearer "+conn.AccessToken)
	req.Header.Add("Content-Type", "application/json")
	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		return result, err
	}
	defer resp.Body.Close()
	result, err = ioutil.ReadAll(resp.Body)
	if err != nil {
		return result, err
	}
	return result, nil
}
func ( conn * RestConnection ) MakeRequest ( method string , url string , payload interface { } , params url . Values ) ( result [ ] byte , err error ) { endpoint := conn . InstanceUrl + " " + url if params != nil && len ( params ) != 0 { endpoint += " " + params . Encode ( ) } var body io . Reader if payload != nil { jsonBytes , err := json . Marshal ( payload ) if err != nil { return nil , err } body = bytes . NewReader ( jsonBytes ) } req , err := http . NewRequest ( method , endpoint , body ) if err != nil { return result , err } req . Header . Add ( " " , " " + conn . AccessToken ) req . Header . Add ( " " , " " ) client := & http . Client { } resp , err := client . Do ( req ) if err != nil { return result , err } defer resp . Body . Close ( ) result , err = ioutil . ReadAll ( resp . Body ) if err != nil { return result , err } return result , nil }
Executes an HTTP Request against the Skuid Pages REST API
Executes an HTTP Request against the Skuid Pages REST API