Search the Community
Showing results for tags 'api'.
Found 5 results
-
Hello, I'm having trouble trying to upload files to my s3 bucket in my Delphi 7 application. I have a python api that generates a presigned url for putting files, and it works perfectly. I am able to send the files to the s3 bucket through Postman, setting the body as binary and the url as the presigned s3 url. Now for the Delphi part, basically what my code does is get the presigned url and send a PUT to it with the TFileStream of a file selected by the user. var SignedURL , res , filePath : string; httpClient : TIdHTTP; SSLIOHandler : TIdSSLIOHandlerSocketOpenSSL; jsonRes : ISuperObject; fileStream : TFileStream begin filePath := 'path/to/file.pdf'; // file selected by user in OpenDialog SignedURL := 'signedUrlGeneratedByPythonCode'; // response from calling my python web api fileStream := TFileStream.Create(filePath, fmOpenRead or fmShareDenyNone); httpClient := TIdHTTP.Create; httpClient.Request.Accept := 'application/json'; SSLIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil); SSLIOHandler.SSLOptions.Method := sslvTLSv1_2; httpClient.IOHandler := SSLIOHandler; try res := httpClient.Put(url, fileStream); jsonRes := SO(res); finally fileStream.Free; httpClient.Free; SSLIOHandler.Free; end; end; With this code I get an access violation at the res := httpClient.Put(url, fileStream); if I run just the Put on runtime, without assigning the response to a variable I get a "Delphi exception EIdSocketError at $2646F905". Removing the SSLIOHandler, I get a "Socket Error #10054 Connection reset by peer.". I'm still a beginner in coding (and very new with Delphi), so I can't pinpoint what exactly could be the problem. I assume it's either because of AWS using HTTPS (although the python api also uses HTTPS and I don't need to set a SSLIOHandler to make a request to it) and my SSL/TLS not working properly or I'm passing the file binaries in the wrong format and the AWS server is refusing the connection instantly. Using: Delphi 7, Indy 10 Thanks in advance, any help would be very much appreciated.
-
Developing apps for GPS related info, i.e., miles/speed/location/etc
JohnLM posted a topic in General Help
I have an e-scooter that I use for riding around towns and trails. There is an app to download. However, that app does not connect to my scooter and the developer is slow to fix/resolve/respond and still does not connect. So, I would like to look into writing my own app for my phone (android) to do the following: 1. track start and end times 3. track my routes - where i've been or stopped at 4. show the miles I am traveling during my ride in real-time 5. show the total miles of my ride 6. possibly show speed (via calculation) and in real-time 7. eventually, to show a map of my route in real-time, and show all my stops Is this possible with Delphi 11.2 and free components/services/API's ? -
I am trying to make an api post request using Delphi. I have the working example in c++ but cannot figure what I am doing wrong when I convert it to Delphi code. I posted my original question on Stackoverflow here: https://stackoverflow.com/questions/74521060/converting-c-api-post-request-into-delphi-code C++ Code: CURL *hnd = curl_easy_init(); curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); curl_easy_setopt(hnd, CURLOPT_URL, "https://sandbox.checkbook.io/v3/check/digital"); struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "accept: application/json"); headers = curl_slist_append(headers, "content-type: application/json"); headers = curl_slist_append(headers, "Authorization: xxxxxxxxxxxx:xxxxxxxxxxxxx"); curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"recipient\":\"testing@checkbook.io\",\"name\":\"Widgets Inc.\",\"amount\":5,\"description\":\"Test Payment\"}"); CURLcode ret = curl_easy_perform(hnd); My Delphi Code: unit API_InvoiceCloud; interface uses DB, SysUtils, System.Classes, System.JSON, IdSSLOpenSSL, VCL.Dialogs, IdHTTP, XML.XMLIntf, xml.xmlDom, xml.XMLDoc, IDCoder, IDCoderMIME, IdBaseComponent, IdException, IdZLibCompressorBase, IdCompressorZLib, Rest.Client; procedure CreateDigitalPayment_CheckBookAPI(mRecipientEmailAddress, mRecipientName : String; mPaymentAmount : Double; mPaymentNumber, mPaymentDescription : String); implementation var //{ INDY COMPONENT TO CONNECT TO API SERVER; MAKES CONNECTION } IDHTTP1 : TidHttp; //{ SSL Connection } SSL : TIdSSLIOHandlerSocketOpenSSL; //{ Request and Response vars } JsonRequest, InJson : String; JsonToSend : TStringStream; //object to store json text and pass API JObj : TJSONObject; Const //{ Constant variables holding the APIKEY+APISECRET and BASEURL } nBASEURL = 'https://sandbox.checkbook.io/v3/check/digital'; nAPIKEY = 'xxxxxxxxx:xxxxxxxx'; procedure CreateDigitalPayment_CheckBookAPI(mRecipientEmailAddress, mRecipientName : String; mPaymentAmount : Double; mPaymentNumber, mPaymentDescription : String); var //{ Response into String } ResponseCode : String; { -----------Testing---------- } //lParamList: TStringList; nBASEURL : String; RequestBody : TStream; ResponseBody : String; begin CodeSite.EnterMethod('DigitalPayment_CheckBookAPI'); nBASEURL := 'https://sandbox.checkbook.io/v3/check/digital'; //{ JSON body with request string } JsonRequest := '{"recipient":"' + mRecipientEmailAddress + '","name":"' + mRecipientName + '","amount":' + FloatToStr(mPaymentAmount) + ',"number":"' + mPaymentNumber + '","description":"' + mPaymentDescription + '"}'; try try //{ Create connection instance } IDHTTP1 := TidHttp.Create; //{ SSL Configuration } SSL := TIdSSLIOHandlerSocketOpenSSL.Create; SSL.SSLOptions.SSLVersions := [sslvTLSv1_1, sslvTLSv1_2]; IDHTTP1.IOHandler := SSL; //{ Headers/Params } IDHTTP1.Request.Clear; IDHTTP1.Request.CustomHeaders.FoldLines := False; IDHTTP1.Request.Accept := 'application/json'; IDHTTP1.Request.ContentType := 'application/json'; IDHTTP1.Request.CustomHeaders.Values['Authorization'] := nAPIKEY; //{ Saving JSON text to TStringStream Object } JsonToSend := TStringStream.Create(JsonRequest, TEncoding.UTF8); //JsonToSend := TStringStream.Create(JsonRequest, TEncoding.ASCII); //{ Making POST Request using INDYs TidHTTP component; Params are: URL, JsonStringObj - saving into variable } SinglePartyResponse := IDHTTP1.Post(nBASEURL, JsonToSend); ShowMessage(IDHTTP1.ResponseCode.ToString); except on E : Exception do //{ Display error message if cannot do API CALL } begin ShowMessage(E.ClassName+' error raised, with message : "' + E.Message + '".'); Abort; end end; finally //{ Free objects from memory } IDHTTP1.Free; SSL.Free; JsonToSend.Free; end; end; end. Any help is appreciated, thanks!
-
Problem with Delphi RIO 10.3.3 and Google API Level 29
Massimiliano S posted a topic in Cross-platform
Hello I need to upload a test app on the google store. Unfortunately, the loading is not successful because Google requires at least a Level 29 for Android 10 as the target of the API while mine is 28. I am using delphi rio 10.3.3 I updated the SDKs by also installing 29 and downloaded the android-ndk-r21d NDK version. I then updated SDK manager set as android-29 target. Unfortunately, delphi always compiles by setting in the manifest: <uses-sdk android: minSdkVersion = "19" android: targetSdkVersion = "28" /> So I forced version 29 in the manifest template but unfortunately the app crashes I read that Delphi RIO theoretically supported the Android 10 version but I could not find anything about my problem other than a 6 month old post with no solution Has anyone found this problem yet? Thanks Massimiliano- 20 replies
-
- api
- play store
-
(and 1 more)
Tagged with:
-
We tried to do one of our own, but appears that it's not that easy. Seems that we can remove them but IDE will, sometimes at least, write them back after that. Or there is no event for dfm when it is saved (Not making the plugin myself so don't know the latest details.) Maybe there is some cool, Andy Magic Of The Hackering, in the DDevExtensions to do this?? Does anyone have ideas how to get that working? -tee-
- 7 replies
-
- ddevextensions
- ide
-
(and 3 more)
Tagged with: