Since
you are setting the Content Type to 'multipart/form-data' that is what
format you would need to supply the loginBody in. You appear to be
generating a JSON like string instead that definitely isn’t
'multipart/form-data'.
However looking at https://enlighten.enphaseenergy.com/login,
it generates a different request to what you are generating via curl and sends
it to https://enlighten.enphaseenergy.com/login/login.
It generates a ‘application/x-www-form-urlencoded’ message but with different
parameters to your example. The fields for the email and password are
called ‘user_email’ and ‘user_password’ and there are lots of other fields such
as authenticity_token. The password appears to be encoded somehow.
Anyway, submitting a login to their login page shows the
form urlencoded message for that end point (this was for an email of j...@test.com and password of 1234)
utf8=%E2%9C%93&authenticity_token=n4N3AqzBSXXtPvZnJwnoVRhf_1ZyBDsfdHmFX2u2ioQvXkPuekeif3Olal1Dw1_9D5-2Y4N-NlxiU7pAOxzFRw&user%5Bemail%5D=joe%40test.com&user%5Bpassword%5D=ab56b4d92b40713acc5af89985d4b786&secured_user=true&commit=Sign+In
VAST will generate url encoded strings via
String>>#sstUrlEncode
If the login.json end point really does take a 'multipart/form-data' message, it is a lot more complex to generate. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#multipartform-data for a sample of what it looks like. VAST has a parser to read ‘multipart/form-data’ messages in SstHttpMultipartContentAssembler, but I’m not aware of a class that can generate them.
Since you are setting the Content Type to 'multipart/form-data' that is what format you would need to supply the loginBody in. You appear to be generating a JSON like string instead that definitely isn’t 'multipart/form-data'.
However looking at https://enlighten.enphaseenergy.com/login, it generates a different request to what you are generating via curl and sends it to https://enlighten.enphaseenergy.com/login/login. It generates a ‘application/x-www-form-urlencoded’ message but with different parameters to your example. The fields for the email and password are called ‘user_email’ and ‘user_password’ and there are lots of other fields such as authenticity_token. The password appears to be encoded somehow.
Anyway, submitting a login to their login page shows the form urlencoded message for that end point (this was for an email of j...@test.com and password of 1234)
utf8=%E2%9C%93&authenticity_token=n4N3AqzBSXXtPvZnJwnoVRhf_1ZyBDsfdHmFX2u2ioQvXkPuekeif3Olal1Dw1_9D5-2Y4N-NlxiU7pAOxzFRw&user%5Bemail%5D=joe%40test.com&user%5Bpassword%5D=ab56b4d92b40713acc5af89985d4b786&secured_user=true&commit=Sign+In
VAST will generate url encoded strings via String>>#sstUrlEncode
If the login.json end point really does take a 'multipart/form-data' message, it is a lot more complex to generate. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#multipartform-data for a sample of what it looks like. VAST has a parser to read ‘multipart/form-data’ messages in SstHttpMultipartContentAssembler, but I’m not aware of a class that can generate them.
From: va-sma...@googlegroups.com <va-sma...@googlegroups.com>
On Behalf Of Louis LaBrunda
Sent: Thursday, August 15, 2024 6:03 AM
To: VAST Community Forum <va-sma...@googlegroups.com>
Subject: A little more SstHttpClient help please
EXTERNAL: Do not click links or open attachments if you do not recognize the sender.
--
You received this message because you are subscribed to the Google Groups "VAST Community Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
va-smalltalk...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/va-smalltalk/1ce8cb3c-1abc-4e15-ad27-7ae7e57d626dn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/ff822136-2abf-488b-8d20-4ca311ae7b36n%40googlegroups.com.
| |||||||||||||||||