idhttp

IdHttp : how to deal with json request and response

放肆的年华 提交于 2020-12-15 06:57:17
问题 I have encountered a few sites that uses JSON for request and response I come across two types : 1- application/x-www-form-urlencoded as request and return a response application/json content type 2- application/json content type for both request and response in type 1 i tried changing the the response content type using mIdHttp.Response.ContentType := 'application/json'; but using http analyzer i can see that it doesn't change and its still text/html now i do not know if the problem is with

IdHTTP how to send raw body

强颜欢笑 提交于 2020-02-21 02:55:50
问题 How i can use IdHTTP to send message as PostMan dos below: My first attempt was as follow: function TIdFoo.SendIM(const AID, AMessage: string): Boolean; const _URL = 'https://URL.com/SendMessage'; var Params : TStringStream; Response : string; LMsg : string; begin Result := False; LMsg := '-----------------------------13932'+ 'Content-Type: application/json; charset=utf-8'+ 'Content-Description: message'+ sLineBreak+ '{"message":{"Type":1,"body":"'+AMessage+'"},"to":["'+AID+'"]}'+ '----------

Failed to decode response content using IdHttp

淺唱寂寞╮ 提交于 2020-02-16 05:48:50
问题 I use TIdHttp to fetch web content. The response header indicates the content encoding to be utf8. I want to print content in console as CP936 (simplified chinese), but the actual content is not readable. Result := TEncoding.Utf8.GetString(ResponseBuffer); I do the same thing in python (using httplib2) without any problems. def python_try(): conn = httplib2.HttpConn() respose, content = conn.get(...) print content.decode('utf8') # readable in console UPDATE 1 I debugged the raw response and

Error 406 Not Acceptable with idHTTP on Android

一世执手 提交于 2020-01-11 09:56:08
问题 I'm trying to post a insert on a MySQL database using idHTTP and a PHP script. This is the PHP script to insert in the database: $mysqli = new mysqli($servidor, $usuario, $senha, $banco); // Caso algo tenha dado errado, exibe uma mensagem de erro if (mysqli_connect_errno()) trigger_error(mysqli_connect_error()); $iduser = quoted_printable_decode($_POST['iduser']); $nome = quoted_printable_decode($_POST['nome']); $data = quoted_printable_decode($_POST['data']); $hora = quoted_printable_decode(

IDHTTP.Post error

蓝咒 提交于 2020-01-05 10:30:11
问题 procedure Texport_plan.cxB_LoadClick(Sender: TObject); var HTTP: TIdHTTP; Query: String; Buffer: TMemoryStream; loadData: Sting; responseData: String; begin try HTTP := TIdHTTP.Create(nil); HTTP.Request.ContentEncoding := 'utf-8'; HTTP.Request.ContentType := 'text/xml'; Application.ProcessMessages; Query := 'http://priem.edu.ru:8000/import/ImportService.svc/import'; loadData := '<Root></Root>' Buffer := TMemoryStream.Create; loadData.SaveToStream(Buffer); responseData := HTTP.Post(Query,

How to create HTTP Header for eBay Browse API Function

落花浮王杯 提交于 2020-01-05 03:38:09
问题 I am trying to get a Product Review Rating through eBay's Browse API. Here is my code for this function: sHeaders := TStringList.Create; sHeaders.Add('X-EBAY-C-ENDUSERCTX=' + '"affiliateCampaignId=' + '533xxxxxxx"'); objIdHTTP.Request.CustomHeaders.AddStdValues(sHeaders); sResponse := objIdHTTP.Get('https://api.sandbox.ebay.com/buy/browse/v1/item/v1|123456789|0'); But I get a Socket Error 10054 when I test this code. It might be something wrong with the customer header part, but I can't

IdHTTP to ensure push data to Ubidots (FMX, WIN32)

岁酱吖の 提交于 2020-01-03 05:09:29
问题 I can push an encrypted piece of humidity data up to my Ubidots cloud database by simply loading the following url in a web browser: https://industrial.ubidots.com/api/v1.6/devices/MYDEVICENAME/?token=MYTOKENHERE&_method=post&humidity=15.9 When I do that, I get the success response in the browser window {"humidity": [{"status_code": 201}]} and the data shows up in my data table on Ubidots. Now, I want to do this from an FMX app (C++ on Win32) without a visible browser, and I would like to

Delphi XE: idHttp & Request.Range, a bug?

青春壹個敷衍的年華 提交于 2020-01-01 18:16:13
问题 I have Delphi XE. I try to set Request.Range of idHttp but I cannot do this. Delphi doesn't allow me to do this neither at design time nor at run time. E.g. I set '6000-' in a design time -> a property gets empty all time. I do (in a thread): Downloader.Request.Range:=(IntToStr(DFileStream.Position) + '-'); synchronize(procedure begin showmessage(Downloader.Request.Range) end); showmessage(Downloader.Request.Range) shows me nothing (an empty string). I checked a request in HTTPAnalyzer -> my

idHttp : error 500 internal server when site is https

喜你入骨 提交于 2019-12-25 09:36:35
问题 I am working on a project involving login and download, for more than 20 site, in some cases, the sites are very alike, even their structure is the same i have encountered a problem recently, some of the same structured sites are http and some are Https , the Http ones are ok and work fine but the Https ones at the very first post return an error 500 internal server when i try to login, the response code shows for security reasons you can not access ... do i need to change my approach with