diff --git a/v5/client.go b/v5/client.go index 06fd460..6544c67 100644 --- a/v5/client.go +++ b/v5/client.go @@ -4173,7 +4173,9 @@ func (c *Client) FileEdit(id int, file File) (FileResponse, int, *errs.Failure) var resp FileResponse req, _ := json.Marshal(file) - data, status, err := c.PostRequest(fmt.Sprintf("/files/%d/edit", id), bytes.NewReader(req)) + data, status, err := c.PostRequest(fmt.Sprintf("/files/%d/edit", id), url.Values{ + "file": {string(req)}, + }) if err != nil && err.Error() != "" { return resp, status, err diff --git a/v5/client_test.go b/v5/client_test.go index e6ed9a7..8f7d2c2 100644 --- a/v5/client_test.go +++ b/v5/client_test.go @@ -4764,16 +4764,7 @@ func TestClient_Files(t *testing.T) { MatchParam("limit", "20"). MatchParam("page", "1"). Reply(200). - BodyString(`{ - "success": true, - "pagination": { - "limit": 20, - "totalCount": 0, - "currentPage": 1, - "totalPageCount": 0 - }, - "files": [] - }`) + BodyString(`{"success": true,"pagination": {"limit": 20,"totalCount": 0,"currentPage": 1,"totalPageCount": 0},"files": []}`) _, status, err := c.Files(FilesRequest{ Limit: 20, @@ -4826,7 +4817,7 @@ func TestClient_FileUploadFail(t *testing.T) { gock.New(crmURL). Post("/files/upload"). Reply(400). - BodyString(`{"success": false, "errorMsg": "error"}`) + BodyString(`{"success":false,"errorMsg":"Your account doesn't have enough money to upload files."}`) _, status, err := c.FileUpload(file) if err.Error() != "" { diff --git a/v5/response.go b/v5/response.go index 72467c8..557c6ca 100644 --- a/v5/response.go +++ b/v5/response.go @@ -371,7 +371,7 @@ type CostResponse struct { type FilesResponse struct { Success bool `json:"success"` Pagination *Pagination `json:"pagination,omitempty"` - Files []File `json:"files,omitempty,brackets"` + Files []File `json:"files,omitempty"` } // FileUpload response