Jump to content

Matt_

Members
  • Posts

    46
  • Joined

  • Last visited

Profile Information

  • Location
    Canada
  • First Name
    Matt
  • Last Name
    Matt

Recent Profile Visitors

355 profile views

Matt_'s Achievements

  1. Their OS is Debian but I'm using shared hosting and they probably have the final says about configuration. Although there's a section where I can select the PHP version and it seems I can edit the php.ini... They're using CGI/FastCGI, $_SERVER['SERVER_SOFTWARE'] says Apache/2. Whether they use Apache or Nginx, it most probably call PHP-fpm to execute any PHP. I'm still dubious if I can actually make changes to allow PUT, but I have hope.
  2. That's great Becquel! Unfortunately for me, we don't have a SSL certificate on our site. In a client (insomnia), when I used https, it gave an error. Although my host has an overall certificate, when I used https://mysite.their_address, it just returns my site and ignore the PUT request.
  3. Hi Using the XML you gave, it return '201 Created' - on my installation. Then when I did a GET for the latest customer it had details for today with firstname as becquel, so it seemed to have worked. If you don't get I assume there's some thing disabled by your host.
  4. Hi Can you view the creation XML? Can you view the XML from ps reply? Ensure the XML that you post doesn't contain the encapsulation "CDATA" and ensure the XML is valid code. The data should abide by the SCHEMA synopsis. Try to POST the same data as an existing user - bar an extra few letters... I have a different computer now and the project is in storage but I can remember most... I used an application called something REST client and it was useful to connect and see the XML code.
  5. Hi There's a few people with comments, but you seem to quote my post... I am unable to PUT correctly, so I'm not the best to advise. But I need to know where your problem is and I'll help where I can. Please provide more information about your issue.
  6. Hi I suspect my host is blocking PUT requests. Using a REST client I can test a variety of requests, only PUT is not working. I tried with "text/xml", "application/xml" and some other formats - no difference! Are you having a problem with POST?
  7. Hi In the past I remember pressing the CANCEL button and it returns to the previous screen - as expected. However it is no longer working. Other javascript actions are working, like the AJAX loading spinner in the top-left corner, AJAX form save, and others. Perhaps it because I'm using Safari, since Chrome and Firefox perform as expected. Here is the code Prestashop uses: I have another web-application but it's using: This works fine in all browsers (the ones listed above). I suggest the input-button-code replace the anchor-code.
  8. Hi You need to be familiar with PHP and SQL and JSON. Create a PHP to perform database queries. <?php require_once 'db.class.php'; DB::$user = 'username'; DB::$password = 'password'; DB::$dbName = 'database'; DB::$host = 'host'; if (isset($_REQUEST['query'])) { $decoded = urldecode($_REQUEST['query']); if (isset($_REQUEST['debug']) && (strtolower($_REQUEST['debug']) == 'on' || $_REQUEST['debug'] == '1')) echo $decoded. " =><br />"; $results = DB::query($decoded); if (isset($results)) { if (isset($_REQUEST['output']) && strtolower($_REQUEST['output']) == 'print_r') echo print_r($results); else { header("Content-Type: text/json"); echo json_encode($results); } } } This code requires your database name, host, username and password to be place in the first few lines. It accept a SQL query has has been URL encoded. It performs the query, using Prestashop's database classes. The result is displayed in JSON format. The code is quite basic but will show you details if you supply good SQL. eg. <my shop url>/querycode.php?query=SELECT * FROM `ps2_module`m JOIN `ps2_module_carrier`mc ON (m.id_module %3D mc.id_module) WHERE m.active %3D '1' AND mc.id_shop %3D '1' (The forum removed most of the encoding from the example above.)
  9. I am unable to successfully make a PUT request using Prestashop's webservice. GET, POST and DELETE work fine. Here is the output from debug on my modified CRUD (like the Prestashop examples https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&ved=2ahUKEwi_lc6Z6aHeAhVM64MKHSnTCaQQFjADegQIAhAB&url=http%3A%2F%2Fdoc.prestashop.com%2Fdownload%2Fattachments%2F327702%2F2-Update.php&usg=AOvVaw0GUs_SLEnNe8nxGvoQzIB-) HTTP REQUEST HEADER GET /api/customers/23 HTTP/1.1 Authorization: Basic VVVYWExHM1pTRExGSTg2SkMyVVNCOTE5VUhFUVU3QVA6 Host: example.com Accept: */* HTTP RESPONSE HEADER HTTP/1.1 200 OK Date: Thu, 25 Oct 2018 14:32:15 GMT Content-Type: text/xml;charset=utf-8 Content-Length: 1876 Connection: keep-alive Keep-Alive: timeout=30 Server: Apache Access-Time: 1540477935 X-Powered-By: PrestaShop Webservice PSWS-Version: 1.7.3.1 Execution-Time: 0.021 Content-Sha1: cbeb8d1c1ba601f49651a99d8753d60ed49e1761 RETURN HTTP BODY <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <customer> <id><![CDATA[23]]></id> <id_default_group xlink:href="http://example.com/api/groups/1"><![CDATA[1]]></id_default_group> <id_lang xlink:href="http://example.com/api/languages/1"><![CDATA[1]]></id_lang> <newsletter_date_add><![CDATA[0000-00-00 00:00:00]]></newsletter_date_add> <ip_registration_newsletter></ip_registration_newsletter> <last_passwd_gen><![CDATA[2018-10-05 06:15:45]]></last_passwd_gen> <secure_key><![CDATA[fa9345d70e28bffb4182397ea63f5176]]></secure_key> <deleted><![CDATA[0]]></deleted> <passwd><![CDATA[$2y$10$J7aqIAyfMdQjZqSYAJwElOJIasNKCmSnPmzJGRjpPxHw2k49UJfJe]]></passwd> <lastname><![CDATA[dd]]></lastname> <firstname><![CDATA[aa]]></firstname> <email><![CDATA[[email protected]]]></email> <id_gender><![CDATA[1]]></id_gender> <birthday><![CDATA[0000-00-00]]></birthday> <newsletter><![CDATA[0]]></newsletter> <optin><![CDATA[0]]></optin> <website></website> <company></company> <siret></siret> <ape></ape> <outstanding_allow_amount><![CDATA[0.000000]]></outstanding_allow_amount> <show_public_prices><![CDATA[1]]></show_public_prices> <id_risk><![CDATA[0]]></id_risk> <max_payment_days><![CDATA[0]]></max_payment_days> <active><![CDATA[1]]></active> <note></note> <is_guest><![CDATA[0]]></is_guest> <id_shop><![CDATA[1]]></id_shop> <id_shop_group><![CDATA[1]]></id_shop_group> <date_add><![CDATA[2018-10-05 12:15:45]]></date_add> <date_upd><![CDATA[2018-10-05 12:15:45]]></date_upd> <reset_password_token></reset_password_token> <reset_password_validity><![CDATA[0000-00-00 00:00:00]]></reset_password_validity> <associations> <groups nodeType="group" api="groups"> <group xlink:href="http://example.com/api/groups/1"> <id><![CDATA[1]]></id> </group> </groups> </associations> </customer> </prestashop> HTTP REQUEST HEADER PUT /api/customers/23 HTTP/1.1 Authorization: Basic VVVYWExHM1pTRExGSTg2SkMyVVNCOTE5VUhFUVU3QVA6 Host: example.com Accept: */* Content-Length: 1400 Content-Type: application/x-www-form-urlencoded HTTP RESPONSE HEADER HTTP/1.1 500 Internal Server Error Date: Thu, 25 Oct 2018 14:32:15 GMT Content-Type: text/xml;charset=utf-8 Content-Length: 282 Connection: keep-alive Keep-Alive: timeout=30 Server: Apache Access-Time: 1540477935 X-Powered-By: PrestaShop Webservice PSWS-Version: 1.7.3.1 Execution-Time: 0.017 XML SENT <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <customer> <id>23</id> <id_default_group xlink:href="http://example.com/api/groups/1">1</id_default_group> <id_lang xlink:href="http://example.com/api/languages/1">1</id_lang> <newsletter_date_add>0000-00-00 00:00:00</newsletter_date_add> <ip_registration_newsletter></ip_registration_newsletter> <last_passwd_gen>2018-10-05 06:15:45</last_passwd_gen> <secure_key>fa9345d70e28bffb4182397ea63f5176</secure_key> <deleted>0</deleted> <passwd>kB670xK3sO</passwd> <lastname>Manager</lastname> <firstname>Yuma</firstname> <email>[email protected]</email> <id_gender>1</id_gender> <birthday>0000-00-00</birthday> <newsletter>0</newsletter> <optin>0</optin> <website></website> <company>qwerty</company> <siret></siret> <ape></ape> <outstanding_allow_amount>0.000000</outstanding_allow_amount> <show_public_prices>1</show_public_prices> <id_risk>0</id_risk> <max_payment_days>0</max_payment_days> <active>1</active> <note></note> <is_guest>0</is_guest> <id_shop>1</id_shop> <id_shop_group>1</id_shop_group> <date_add>2018-10-05 12:15:45</date_add> <date_upd>2018-10-05 12:15:45</date_upd> <reset_password_token></reset_password_token> <reset_password_validity>0000-00-00 00:00:00</reset_password_validity> <associations></associations> </customer> </prestashop> RETURN HTTP BODY <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <errors> <error> <code><![CDATA[127]]></code> <message><![CDATA[XML error : String could not be parsed as XML XML length : 0 Original XML : ]]></message> </error> </errors> </prestashop> Other errorThis call to PrestaShop Web Services failed and returned an HTTP status of 500. That means: Internal Server Error. Summary: It sends a GET request, for the supplied customer, and displays it in a form. When the UPDATE button is clicked, it issues a PUT request of the entered data. Can somebody test this on their installation to determine whether I'm doing it correctly. (You'll need to create an API webservice key [with all permissions] and a test customer [that can deleted later]. Then update that customer with some random data. Please share the debug output - remember to remove the Host or Authorization.) (Attached: CRUD Tutorial - Update example) 2-Update.php
  10. Hi There's a switch in `Advanced Parameters > WebService`: Enable CGI mode for PHP Before choosing "Yes", check that PHP is not configured as an Apache module on your server. Is there a method to check this via code? Like can it not be a silly value in the root .htaccess and test is a 500 error is returned... or whatever...? The operator at my web host, first said no then yes ... How can I know for sure?
  11. Can someone help me? I'm stuck on PUT, where I update a record and send it back. With POST - to insert a new record, I first GET the blank schema insert my details (in plain text) then POST the construction to the same URL and it does the magic and sends a response of the entire record with formatted details including the assigned id. Works fine! But with PUT - to update the details, I. first GET the record (by id) change as is needed then I PUT the XML back to the same URL. So it is similar to above, but it fails: <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <errors> <error> <code><![CDATA[127]]></code> <message><![CDATA[XML error : String could not be parsed as XML XML length : 0 Original XML : ]]></message> </error> </errors> </prestashop> How is the PUT different, what extra steps are needed?
  12. I have further tests to go... but the problem seems to be that I added an extra line (and it's closer). Specifically `"<customers>"` One test worked with a REST client application (by WizTools.org) and its respond was as excepted. I assume that the extra wrapper caused the invalid XML error... testing properly UPDATE I successfully created a new customer! Found in the request, the data shouldn't be wrapped in CDATA (ie. <abc><![CDATA[input_data]]></abc> where I want insert input_data in abc) now to PUT...
  13. Hi I just tried to upgrade (from 1.7.1.1 -> 1.7.1.3). But a similar situation happens almost every time. (I guess the issue is due to a few rouge files that became corrupt from my FTP client - asked web host technical assistance.) Is there a way to manually place this file? After that can I instigate the database upgrade manually? (I assume this wasn't done...it may have...) Error logs show: PHP Fatal error: Uncaught exception 'Symfony\Component\Filesystem\Exception\IOException' with message 'Cannot rename ".../app/cache/prod/translations/catalogue.fr-QC.8739602554c7f3241958e3cc9b57fdecb474d508.php.me5czIG4" to ".../app/cache/prod/translations/catalogue.fr-QC.8739602554c7f3241958e3cc9b57fdecb474d508.php.meta".' in .../vendor/symfony/symfony/src/Symfony/Component/File 20180624T074854: .../index.php PHP Fatal error: Uncaught exception 'Symfony\Component\Filesystem\Exception\IOException' with message 'Cannot rename ...app/cache/prod/translations/catalogue.fr-QC.8739602554c7f3241958e3cc9b57fdecb474d508.phpMJH7iA" to ".../app/cache/prod/translations/catalogue.fr-QC.8739602554c7f3241958e3cc9b57fdecb474d508.php".' in .../vendor/symfony/symfony/src/Symfony/Component/Filesystem/F 20180624T124346: .../admin.../autoupgrade/ajax-upgradetab.php PHP Warning: filesize(): stat failed for .../simple/20170422/tutorial/images/download/download.pngZone.Identifier in .../modules/autoupgrade/AdminSelfUpgrade.php on line 3709 20180624T133113: .../admin.../autoupgrade/ajax-upgradetab.php PHP Fatal error: Call to a member function can() on a non-object in .../src/Adapter/Module/AdminModuleDataProvider.php on line 165
  14. Can anyone provide anything that may help?
  15. Hi How can I send a PUT / POST HTTP request, without PHP? I have used PHP a heap, but now I writing for a smartphone. (Using Swift, Java and was C#). (If asked, I can show the swift code that I use.) GET is simple, you can also just put the URL in a web browser to get a response. I have several functions to get customers, addresses, products, etc. and these work well. (I have many object models - like a database table structure - that store the data.). (Because JSON is much easier to decode/encode, I apply "&output_format=JSON". If only I could also PUT / POST JSON...) However when it comes to making a PUT / POST (and probably DELETE in the future...) request I keep getting errors. (I know this is probably the wrong way: but I created a module where you can POST the customer's email and password. The template would provide either the complete customer record - if validated - or "BAD" if no record with matching details was found. The request content is like "email=xxx&passwd=yyy" (application/x-www-form-urlencoded) and is translated to UTF-8; then the Content-Length is set.) Using Fiddler, I can view the exact transaction (request & response): [see: https://ibb.co/kC0QTy] When I attempt a PUT request and I send XML (wish I could send JSON instead): PUT http://example.com/api/customers?ws_ket=ABC..XYZ Content-Type: application/xml; charset=utf-8 Accept: */* ... <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <customers> <customer> <id> ... </customer> </customers> </prestashop> It responds with: HTTP/1.1 500 Internal Server Error Content-Type: text/xml; charset=utf-8 ... <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <errors> <error> <code><![CDATA[127]]></code> <message><![CDATA[XML error : String could not be parsed as XML XML length : 0 Original XML : ]]></message> </error> </errors> </prestashop> And much the same for a POST. What do I need to send XML, using PUT and POST?
×
×
  • Create New...