Iām trying to simply login via the API (v4.1). I added log messages to public/legacy/service/v4/SugarWebServiceImplV4.php, at the top of the login function:
Hi,
did you hash your password? You need so send it as md5, so instead of ātestā you would send ā098f6bcd4621d373cade4e832627b4f6ā (I see your pw looks like a hash, but its a common mistake).
Yes, the password is an MD5 hash and I was careful to not include line breaks in the input. I generated the MD5 hash via the terminal printf password | md5sum and verified in an online MD5 generator.
Note that I am sending the payload as application/www-x-form-url-encded key/value pairs, with the rest_data value being raw (URL-encoded) JSON. Is this correct?
Iāve read the guide numerous times, itās not enough. I am not using PHP and am not a āPHP guyā. Of course I can understand it but donāt know the inner-workings.
Given my POSTād request above, what is wrong with it?
Yes, Iām using Postman. Whatās unclear to me (and isnāt mentioned in the docs that I could find), is what the Content-Type should be. I believe it is meant to be application/x-www-form-urlencoded. So Iāve tried sending the payload as form variables and I also tried as JSON (with application/json). It seems like no matter what I do, the parameters are not parsed on the PHP side.
I updated the login function to immediately return the incoming arguments (and my rebuilt request variable), so you can see here exactly what is being sent to the function:
Can you please try using āParamsā option as follows and if it works, you can debug/check in the code about the content-type/length. The file rest.php uses āSugarRestServiceā object and āSugarRestJSONā response object. Please check in the serve() method in \service\core\REST\SugarRestJSON.php.
Using the āparamsā option puts the params in the URL as query params. Iāve tried this directly via curl and Postman and I get the same result. Thank you, though.