func (client *Client) post(path string, params map[string]interface{}, options *grequests.RequestOptions) (*simplejson.Json, error) { if options == nil { options = client.provider.options() } options.JSON = params resp, err := grequests.Post(client.provider.baseURL()+path, options) if err != nil { return nil, err } if !resp.Ok { return nil, NewErrorFromBody(resp.String()) } return simplejson.NewFromReader(resp) }
// Function roBody configures a RequestOptions object with the appropriate type of body (XML, JSON) func roBody(inOp *grequests.RequestOptions, inRq *tRequests) (rErr error) { // Is this a POST? if inRq.Method != "POST" { rErr = errors.New("ERROR: Fn roBody - expecting a POST but received a GET request") return } // Configure a JSON or XML request body switch inRq.Typebody { case "application/json": inOp.Headers = contJSON inOp.JSON = inRq.Body case "application/xml": inOp.Headers = contXML inOp.XML = inRq.Body default: rErr = errors.New("ERROR: Fn roBody - did not receive an XML or JSON request object") } return }