- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我花了一整天的时间试图找出这个问题。在这里发布这个问题是我最后的希望。我希望有人能帮助我继续从事第一份工作。
因此,当直接将数据从我的 View 直接传递到 RestServer 时,POST 工作正常。但是,RESTServer API 无法找到从 RestClient 发送的 POST 数据。
以下是片段:
RestClient API:
$ver = 'v1';
$config = array('server' => base_url()."v1",
'api_key' => 'xxxxxx',
'api_name' => 'X-API-KEY',
'http_user' => 'admin',
'http_pass' => 'xxxxx',
'http_auth' => 'basic',
);
$this->rest->initialize($config);
$this->rest->format('application/json');
$param = array(
'id' => $this->input->post('id'), // works fine here
'name' => $this->input->post('name')
);
$user = $this->rest->post('employer/postNewProject', $param, 'json');
//if (isset($user->errors)) show_404('admin');
$this->rest->debug();
休息服务器接口(interface)
class Employer extends REST_Controller
{
public function __construct()
{
parent::__construct();
$this->lang->load("application");
$this->load->library("users/auth");
Datamapper::add_model_path( array( APPPATH."modules" ) );
}
public function postNewProject_post()
{
// I tired $this->post() and $this->input->post() but both not finding the data
$message = array("id" => $this->post("id"), "name" => $this->input->post("name"));
$this->response($message, 200); // 200 being the HTTP response code
}
}
结果:
Response when using $this->post('id');
{"id":false}
Response when using $this->post();
{"id":[]}
注意:我已经用硬编码数据替换了 POSTS 请求,但 RestServer 仍然无法从我的 RestClient 接收数据。
如果您需要我提供任何其他信息,请询问。
提前谢谢你。
最佳答案
使用此方法使用 post 方法将 Rest 客户端数据发送到 Rest 服务器。阅读每一行的评论
// initialize you setting
$config = array('server' => base_url() . "v1",
'api_key' => 'xxxxxx',
'api_name' => 'X-API-KEY',
'http_user' => 'admin',
'http_pass' => 'xxxxx',
'http_auth' => 'basic',
);
$this->rest->initialize($config);
// Set method of sending data
$method = 'post';
// create your param data
$param = array(
'id' => $this->input->post('id'), // works fine here
'name' => $this->input->post('name')
);
// url where you want to send your param data.
$uri = 'employer/postNewProject';
// set format you sending data
$this->rest->format('application/json');
// send your param data to given url using this
$result = $this->rest->{$method}($uri, $params);
// Controller 代码 employer/postNewProject
Controller
function postNewProject()
{
$data=array(
'id' => $this->post('id'),
'name' => $this->post('name')
);
print_r($data);
}
关于php - CodeIgniter 将 POST 数据从 RestClient 传递到 RestServer API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24682347/
我目前正在与 Personio 集成以获取员工数据。 下面的解决方案不是等待响应,而是在代码中注释的地方突然跳出第二个方法: using Personio.Client.Configuration;
我想知道通过 CDI 注入(inject) RestClient 时 quarkus 的行为是什么。 在下面的例子中它会自动关闭客户端吗? @Produces(APPLICATION_JSON) @C
ASP.Net HttpClient 是一次性的,很多文章都说由于性能原因应该使用单例模式来使用它。但是当我看到 RestClient 时,它无法被处置,并且在 Recommended-Usage 中
我可以从此处的说明中记录如下所示的简单请求 Logging RestClient in a Rails app 它记录请求,但不记录调用的响应。 有没有告诉 RestClient 也记录响应? 最佳答
我正在使用JSON对象使用Spring MVC。当我尝试从RESTClient发送JSON对象时, HTTP Status 400 - The request sent by the client w
我想在 ruby 中安装 restclient。我收到这些消息: Building native extensions. This could take a while... ERROR: E
我有一个条件,我需要将参数作为散列数组传递,如下所示: 以下是 API 调用的 Rack::Test post 方法。 post "#{url}.json", :api_key => applicat
我的请求看起来像这样,但是当我尝试运行此代码时,出现此错误: @Grab(group='org.codehaus.groovy.modules.httpbuilder',module='http-bu
我无法导入 RESTClient在我的 grails 项目中。消息是: Groovy:unable to resolve class groovyx.net.http.RESTClient 在 Bui
admin-on-rest允许通过编写自定义 rest 客户端来使用任何 JSON 响应。文档中的示例用于使用来自 json-server 的 JSON project这很简单。 我想知道消费它有多容
我正在使用 RestSharp.RestClient (105.2.4-rc4-24214-01) 开发 .net core 应用程序。我设置了 RestClient.Timeout=1 或 Rest
我正在尝试使用 Terremark 企业云中的 REST Web 服务之一。这是我所做的:1)获取xsd并生成jaxb工件2) 发送 Rest 调用并让 Restclient 填充 Organizat
我收到一个 NullpointerException 但我什至不明白怎么可能。我只是从其他类复制粘贴了 RestTemplate restTemplate = this.restClient.getR
我正在通过 selenium IDE 测试注册流程。我正在使用 REST 客户端获取数据并从获得的结果中提取特定信息(在我的代码 ID 中)。当我删除(对于 delete 方法)一段代码并重复它直到我
这是我的代码片段 console.log("IS RESTCLIENT UNDEFINED?"); console.log(restClient === undefined); conso
我正在进行 RESTful WS 调用,如下所示: ResponseEntity responseEntity = restTemplate.exchange(url,
能否请您更正我在调用 http delete 时在这里犯的错误。我收到 InternalServerError,没有进一步的解释。 相同的调用在 FireFox RESTClient 插件上运行良好。
我正在尝试为我的解决方案安装 CodeIgniter RESTClient 和 RESTServer 库。 ( philsturgeon-codeigniter-restclient 和 chrisk
任何人都知道 RestSharp 的默认超时值休息客户端? 最佳答案 RestSharp 在后台使用 HttpWebRequest,它有一个 default timeout 100 秒。 关于http
我试图了解 RestClient.send 的定义位置无济于事:-( 让我向你解释一下我的意思: 我一直在查看 iqengines.com ruby api gem,他们使用 RestClient
我是一名优秀的程序员,十分优秀!