Ian Branch
-
Content Count
1272 -
Joined
-
Last visited
-
Days Won
3
Posts posted by Ian Branch
-
-
8 hours ago, JohnLM said:I managed to finally get one project to work, found via google search. I can send a text to another vcl app in windows.
Any chance of providing the link?
Or a copy of your working example?
Regards & TIA,
Ian
-
CRACKED IT!!!!
As Patrick suggested, put the Json request into the Custom body.
It didn't work for me the first time as I suspect I had the Json constructed wrong, and I still had Parameters in the RESTRequest.
All sorted now. Now to actually create the App. 🙂
My thanks to all that contributed to my first foray into REST. Appreciated.
Regards,
Ian
- 1
-
-
Hi Patrick,
7 minutes ago, Patrick PREMARTIN said:Try to pass the parameters as BODY fields instead of GET/POST.
You mean put this:
"{"username": "email@mail.com", "secret":"password","shortcode":pacificbulksms","msisdn":"6798688008","message":"Hello James..."}"
into the Custom body? With the correct values of course. 😉
I just tried that, same result.
Ian
-
15 minutes ago, Uwe Raabe said:The default parameter kind is pkGetOrPost,
Hi Uwe,
What should this parameter be?
All the parameters basically look like this:
Ian
-
-
Correction! I thought it had been successful in the Debugger but I was looking in the wrong place. 😞
Still an Empty Request error.
This is the Debugger Request Tab:
This is the Parameters Tab, with key info changed: 😉
You will note the 'Response' says 200:OK..... But the Tabular Data Tab says it was an error.
I spoke to the Phone owner and he hasn't received any messages.
I'm confused.
Ian
-
Hi Patrick,
When I put the Parameters into the REST Debugger, it says it is successful.
When I have the parameters in the RESTRequest and right-click|Run, it is successful.
But, If I leave The Client and Request exactly the same and inthe Delphi App do RESTRequest1.Execute, it fails. 😞
procedure TForm12.btnComponentsClick(Sender: TObject); var obj, code, data: TJSONObject; sCode, url: string; begin // // Call the REST API and handle the response RESTRequest1.Execute; // ShowMessage('Status Code = ' + RESTResponse1.StatusCode.ToString); obj := RESTResponse1.JSONValue as TJSONObject; scode := obj.Values['code'].Value; data := obj.Values['data'] as TJSONObject; url := data.Values['text'].Value; ShowMessage('Code = ' + scode + sLineBreak + 'Text = ' + url); end;
Returning 'Status Code = 200' for the first ShowMessage, and 'Code = 302 Text = Empty Request.....' for the second showmessage. 😞
Regards,
Ian
-
So, I got test parameters from Vodafone.
When I run the App I get a 'Empty Request...' message.
Clearly I have missed setting something. 😞
Ian
-
Hi Team,
I'm back. Thank you for your inputs.
I have this so far:
procedure TForm12.Button1Click(Sender: TObject); begin // // The RESTClient has already been configured. // RESTRequest1.AddParameter('username', 'email@email.com'); RESTRequest1.AddParameter('secret', 'password'); RESTRequest1.AddParameter('shortcode', 'pacificbulksms'); RESTRequest1.AddParameter('msisdn', '6799998122'); // I take it this is the destination mobile Phone #?? RESTRequest1.AddParameter('message', 'Hello World'); // Call the REST API and handle the response RESTRequest1.Execute; // Access the response content if RESTResponse1.StatusCode = 200 then begin // Process the response content (e.g., RESTResponse.Content) var sResponse := RESTResponse1.Content; Label1.Caption := sResponse; // // Example response {"result":"success","code":"200","data":{"text":"SMS sent successfully."}} var sResult := GetResponseParameters(sResponse, 3, 4); var sCode := GetResponseParameters(sResponse, 7, 8); var sMessage := GetResponseParameters(sResponse, 13, 14); end else begin // Handle error cases end; // end;
The RESTClient has the BaseURL set as "https://pacificbulksms.com".
The RESTRequest has the Resource set as "api/restJson".
Are there any other default settings I need to change, or settings I need to make?
Aside of course getting actual usable test parameters from Vodaphone. 😉
Regards & TIA,
Ian
-
Tks Thomas.
Changing "Sender: TObject" to "Dataset: TDataset" did the trick.
Regards & Tks again,
Ian
-
Hi Team,
I am trying to assign the AfterEdit event to a TTable.
I have this in the private area:
procedure jtAfterEdit(Sender: TOBject);
I have this in the DatamoduleCreate;
JobTickets.AfterEdit := JTAfterEdit;
And this as jtAfterEdit:
procedure TdmC.JTAfterEdit(Sender: TOBject); begin // JobTickets.FieldByName('UserID').AsString := AUD.UserID; lNewRecord := False; // Specifically reset the flag. // end;
Delphi tells me that "[dcc32 Error] dmCurrent.pas(861): E2010 Incompatible types: 'TDataSet' and 'TObject'" for this line:
JobTickets.AfterEdit := JTAfterEdit;
What have I missed pls?
Regards & TIA,
Ian
-
Hi Team,
I haven't forgotten this, just dealing with some issues for a Customer.
-
Hi Team,
My Customer has asked me if I can add SMS sending to his Apps.
In support he has sent me a document from Vodafone, he is a repairer for Vodafone, with the following information.
I know absolutely nothing about REST and/or its usage in/with Delphi.
Could I prevail on someone to create a small delphi unit that incorporates whatever is necessary to send an sms?
It would be very much appreciated.
Regards & TIA,
Ian
-
Hi Team,
In some places, not all, the use of a Credit Card to pay by a Customer incurs a 'Bank Fee' on the Seller.
The Seller offsets this by adding an appropriate 'Bank Fee' to the sale.
Question - Where VAT/GST applies, the Sale will incur a VAT/GST as part of the Sell Price. Does the 'Bank Fee' also incur the VAT/GST?
What is the general experience/knowledge?
Regards & TIA,
Ian
-
In my early Delphi days I used FastReport however at that time it didn't/couldn't do what i needed so I moved to ReportBuilder.
Since then I have never seen or come across a reason to look for another report engine.
Ian
-
Hi Team,
I redid my routine to use StrCmpLogicalW. Now I get...
uses System.Generics.Defaults; procedure SortStringArray(var AStringArray: TArray<string>); var Comparer: IComparer<string>; begin Comparer := TComparer<string>.Construct( function(const ALeft, ARight: string): Integer begin Result := StrCmpLogicalW(PChar(ALeft.ToLower), PChar(ARight.ToLower)); end ); // Sort the string array using the custom comparer TArray.Sort<string>(AStringArray, Comparer); end;
Regards & Tks.
Ian
-
Hi Team,
I have been following this thread because I have a need.
What would be the correct natural sort order for these?
'file10.txt', 'File2.txt', '2fileb.txt', 'file1.txt', '1FileA.txt', 'file20.txt', '12fiLe.txt', 'file11.txt', '10file.txt'
Is there a reference for dictating Natural Sort Order rules?
I have my own StringArray Natural Sorting routines and they seem to work. I just want to make sure they are giving me the correct result IAW NSO rules.
This is what I am producing att:
Regards & TIA,
Ian
-
I did say Tks = Thanks.
-
Excellent!
Tks p2k.
-
Hi Team,
D11.3.
Is there a way to pickup the number at build/compile time so I can include it in a log message?
e.g. something like..LogMessage('This is line # '+%LineNumber%);
I know I can hard code it but it would need to be re-done every time there is a code change.
Regards & TIA,
Ian
-
14 hours ago, Uwe Raabe said:Some people found it helpful to manually uninstall all GetIt packages before the update and re-install them afterwards. The installer seems not to handle that very well by itself.
I Third that...
-
"Intelligence" - I think, therefore I am..
-
Hi Team,
Despite my pitiful efforts I have managed to get App Tethering working between two Apps.
But, I have a problem. IIUC, the Sender has to be running before the Receiver. Something about establishing a socket
This I can't guarantee. 😞
Is there any way to configure App Tethering so it dosn't matter if the Sender or Receiver starts first??
Regards & TIA,
Ian
'Default Sort All Classes' issue.
in MMX Code Explorer
Posted · Edited by Ian Branch
Hi Uwe,
D11.3, latest MMX.
If I have this code in my type declaration:
{code}
....
procedure FormShow(Sender: TObject);
procedure IndexOrdChange(Sender: TObject);
private
const iWidth = 920;
end;
implementation
''''
{code}
The function changes it to this:
{code}
....
procedure FormShow(Sender: TObject);
procedure IndexOrdChange(Sender: TObject);
private
const <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
const iWidth = 920;
end;
implementation
''''
{code}
Which of course causes an error.
If I have this:
{code}
....
procedure FormShow(Sender: TObject);
{$IFDEF MyTest}
procedure IndexOrdChange(Sender: TObject);
{$ENDIF}
private
const iWidth = 920;
end;
implementation
''''
{code}
It removes the $IFDEF/$ENDIF block totally.
Regards,
Ian