warrios96 Posted March 16, 2021 Share Posted March 16, 2021 (edited) Hello, I have prestashop 1.7.7.2 and I am developing an api in C # to communicate with the store. I want to add attachments (* .pdf) to my products. From the backend I see that they can be uploaded. But I have not seen any resource in the webservice to be able to access and upload those files and attach them to my products. I also do not see that the products have any XML tag to be able to upload it. I have something implemented very similar to uploading the images but I don't know what url to send the raw pdf to be saved. Any ideas ?, I hope I have explained myself well. Edited March 16, 2021 by warrios96 (see edit history) Link to comment Share on other sites More sharing options...
fabianf Posted May 17, 2021 Share Posted May 17, 2021 I have the same problem. The attachmemts ressource does not seem to be availaible in the webservice. Link to comment Share on other sites More sharing options...
warrios96 Posted May 18, 2021 Author Share Posted May 18, 2021 (edited) In prestashop 1.7.8 I guess it will work. Attachments Edited May 18, 2021 by warrios96 (see edit history) Link to comment Share on other sites More sharing options...
sebma Posted June 17, 2021 Share Posted June 17, 2021 (edited) Hello, did anyone manage to upload the attachments in 1.7.8? i try curl, i get code 200, no attachment My code: url = 'http://xxxxxx/api/attachments/'; $key = 'xxxxxx'; $args['file'] = new CurlFile($att_path); $args['file_name'] = 'file_name'; $args['mime'] = 'image/jpeg'; $args['name'] = 'name'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_USERPWD, $key.':'); curl_setopt($ch, CURLOPT_POSTFIELDS, $args); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); $httpCode = curl_getinfo($ch); curl_close($ch); Edited June 17, 2021 by sebma Add code (see edit history) Link to comment Share on other sites More sharing options...
rodrigoew Posted March 10, 2022 Share Posted March 10, 2022 Hello in 1.7.8 In the class: /classes/webservice/WebserviceSpecificManagementAttachments.php * Examples: * [GET] https://domain.tld/api/attachments/ give a response in XML/json with all attachments. * [POST] https://domain.tld/api/attachments/ only creates model information (similar to any other default api), no file information. * [POST] https://domain.tld/api/attachments/file creates an attachment AND uploads a file for it. * * [PUT] https://domain.tld/api/attachments/$id_attachment here urlSegment[1] is id_attachment, updates model information only. * [PUT] https://domain.tld/api/attachments/file/$id_attachment here urlSegment[1] is 'file' and urlSegment[2] is id_attachment, updates file (binary) only. * * [GET] https://domain.tld/api/attachments/$id_attachment gives a response in XML/json for the attachment model information. * [GET] https://domain.tld/api/attachments/file/$id_attachment downloads the id_attachment file So the curl is this one: curl -v -X POST --form '[email protected]' 'https://WSKEY@HOST/api/attachments/file' > xml2.xml And you get the info in the xml. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now