问题标签 [unirest]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
161 浏览

php - curl_setopt_array(): CURLOPT_FOLLOWLOCATION

警告: curl_setopt_array(): CURLOPT_FOLLOWLOCATION 在设置 open_basedir 时无法激活。

我正在尝试安装 Unirest,当我执行 php 文件时,我收到了这个错误消息

0 投票
1 回答
8617 浏览

java - 在 Unirest 中获取本机 REST 服务错误

我们使用 Unirest 作为 REST 客户端。下面是我们用来调用 REST 服务的示例代码

这绝对是 REST 服务返回 json 的时候。如果出现错误,我正在使用的 REST 服务不会返回 json 响应。相反,它返回 html 错误页面。

由于 Unirest 正在尝试将 html 转换为 json,因此出现以下问题

在这种情况下,我们只是得到了这个 InvalidJsonException 并且实际的 html 错误页面丢失了。我们需要在我们的应用程序中显示 html 错误页面以防出错。

在这种情况下,我们如何获得原始 REST 服务错误?

0 投票
1 回答
975 浏览

javascript - 可以将响应设置为 ArrayBuffer 客户端,但不能使用 Node.js

我有一个使用 XMLHTTPResponse 的客户端表单,它允许我获取保存为文件的响应数据。在其余的 blob 转换发生之前,它将响应类型设置为 arraybuffer,如下所示:

我一直在搜索并找到多种创建数组缓冲区的方法,但没有详细说明如何将节点中的响应带到数组缓冲区。我正在使用 unirest 如下:

如何将响应类型设置为 arraybuffer 或将响应转换为 arraybuffer?

0 投票
1 回答
1603 浏览

java - Java 的 Unirest

我有一个 Python 脚本,它将数据发布到服务器 url,如下所示。我想使用 unirest for Java 来实现这一点。如何在 Java 中为 unirest post 请求添加参数/标头值

Python脚本:


服务器端点代码是:


java中最统一的代码是什么?下面的代码是否会达到与 python 脚本相同的结果

0 投票
0 回答
584 浏览

javascript - Javascript - 错误:未定义要求

我最近安装了 unirest。

在他们的文档中,他们提供了以下代码来测试 unirest:

当我添加这段代码时,我在控制台中收到以下错误:

我网站的整个 UI 也停止工作。

我以前使用过require,它从来没有给我这个错误。有什么我忘记包括的吗?

编辑:忘了提。是的,我在 Node.js 环境中运行它。

0 投票
1 回答
956 浏览

php - 将 Curl 转换为 Unirest

这是来自 Stripe API curl 方法的 curl 请求:

现在我有这个唯一的代码:

条纹返回方法是错误的。我认为它是-ucurl 的参数。

0 投票
1 回答
1060 浏览

playframework - playframework 1.4 中的连接超时

使用 Unirest 库从一个控制器向另一个控制器发出 GET 请求时,我总是遇到连接超时

应用程序运行在

我的代码Slash extends Controller是:

在日志中我有:

路径/api/link/{str}被路由到另一个类扩展控制器。

直接向 请求时http://localhost:9000/api/link/HZbeTR,只需几毫秒,我就有响应。

我调试了网络,发现没有像这样的请求GET http://localhost:9000/api/link/HZbeTR

我也提出String URL = "http://yandex.ru"了 Unirest 并成功地向 Yandex 提出了请求。

0 投票
1 回答
302 浏览

node.js - How to cancel a unirest request in nodejs

I have a node process running that do some unirest.get and unirest.post from time to time. I also have a type of web terminal from which I can see the overall progress of said unirest requests.

The problem is that I need to be able to cancel a specific request, but I can't find out how.

The structure is something like this:

And I want to do something like:

since in this case I can't let the callback fires, since the goal is to cancel it to request the same url again, and without canceling it the callback would fire twice.

Anyone knows how to cancel/interrupt/destroy it?

0 投票
1 回答
1852 浏览

node.js - Google Cloud Print API - 打印 PDF 时出现白页

我想使用 Google Cloud Print API 发送要打印的 PDF 文件。下面的代码会给我一个积极的消息,告诉我生成了一个页面。当我去检查结果时,我打开了一个空白页面。

如果我将打印件保存在 Google Drive 上,也会出现同样的结果。

编码

我知道我发送的是 PDF,因为当我更改

我将获得 53 页文本,这是 PDF 文件的原始内容。

在此处输入图像描述

问题

我做错了什么?

技术规格

  • NodeJS v4.1.1
  • 统一 v0.4.2
0 投票
0 回答
1165 浏览

php - 解析 Unirest PHP 的响应

我正在使用 Unirest PHP 调用 API。它看起来像这样:

响应正文包含很多信息。这是一个标准类对象。我该如何解析这个?我尝试像在 JSON 中那样解析它,但出现错误。响应如下所示:

我想要的只是响应中的 300,它发生在最后。