You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Free Pascal向含冒号的dweet.io URL提交数据失败问题排查

解决Free Pascal/Lazarus中提交带冒号的dweet.io事物名称失败的问题

我正在使用dweet.io平台,无需注册即可直接提交字段/值并展示,还能在freeboard.io中通过图形仪表查看数据。

curl提交示例

使用curl提交带冒号的事物名称:kpv1可以成功:

$curl 'https://dweet.io/dweet/for/:kpv1?volt1=622&volt2=624&volt3=600'
# 响应结果:
{"this":"succeeded","by":"dweeting","the":"dweet","with":{"thing":":kpv1","created":"2023-11-05T19:03:17.892Z","content":{"volt1":622,"volt2":624,"volt3":600},"transaction":"98967dcf-168d-4c78-a190-9476ff95e9cd"}}

直接在浏览器输入该URL也能得到相同结果,访问对应地址可查看提交的数据。

问题代码

我用Free Pascal/Lazarus编写了带TEdit和TButton的GUI窗体代码,尝试发送POST请求:

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, opensslsockets, fphttpclient;
type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
  private

  public

  end;

var
  Form1: TForm1;
  URL, S : String;

implementation

{$R *.lfm}

{ TForm1 }                            
procedure TForm1.Button1Click(Sender: TObject);
begin
  URL := 'https://dweet.io/dweet/for/:kpv1?volt1=922&volt2=924&volt3=900';
    S := TFPCustomHTTPClient.SimplePost(URL);
  Writeln(stderr, S);
  Edit1.Text:=S;
end;  

点击按钮后无任何反应,dweet.io未更新,Edit1.Text为空,stderr也无输出。

临时解决方法

发现问题出在dweet.io的事物名称上:将:kpv1改为kpv1(移除冒号)后,代码正常运行:

URL := 'https://dweet.io/dweet/for/kpv1?volt1=922&volt2=924&volt3=900';
S := TFPCustomHTTPClient.SimplePost(URL);
// Edit1.Text收到的响应:
// {"this":"succeeded","by":"dweeting","the":"dweet","with":{"thing":"kpv1","created":"2023-11-05T20:09:47.833Z","content":{"volt1":922,"volt2":924,"volt3":900},"transaction":"7177dc55-a174-4edd-b88d-fd64cc4dad9f"}}
// 提交到dweet.io的kpv1数据可在对应地址查看

提问

请问如何解决带冒号的事物名称提交失败的问题?


内容的提问来源于stack exchange,提问作者George Vasiliou

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 00:07:03