解析服务器云代码功能“无法POST” [英] Parse-server cloud code function 'Cannot POST'

查看:172
本文介绍了解析服务器云代码功能“无法POST”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的迁移到开源解析服务器的大多数部分都是成功的,我的数据正确存储,可访问。



但我遇到了云代码的问题,特别是运行简单的curl测试。



初始语法分析服务器安装包括一个包含hello world函数的main.js示例文件。



My自己的解析安装托管在/ parse,所以URL使用它作为根



以下是一个简单的请求测试

  curl -X POST \ 
-HX-Parse-Application-Id:myAppId\
-HX-Parse-REST -API-key:myRESTKey\
-HContent-Type:application / json\
-d'{}'\
http:// localhost:1337 / parse / 1 / functions / hello

我得到的响应是


无法POST / parse / 1 / functions / hello


是卷曲的perfunctory语句,它找不到一个合适的POST端点



这里出了什么问题?我只是简单地更改了样例curl示例从Parse.com的文档关于使用云代码使用我的解析服务器安装细节

解决方案

答案是,与Parses托管解决方案不同,API版本路径不是由parse-server



托管的东西(如果您主机解析为eg:/ parse) ,那么这是函数API可用的相对URL。所以只需从路径中删除/ 1 /。

同样的curl命令适用于此URL



http:// localhost:1337 / parse / functions / hello



例如:

  curl -X POST \ 
-HX-Parse-Application-Id:myAppId \\
-HX-Parse-REST-API-Key:myRESTKey\
-HContent-Type:application / json\
-d'{}'\\ \\
http:// localhost:1337 / parse / functions / hello


Most parts of my migration to open source parse-server are successful, with my data correctly stored, accessible.

I am however having problems with cloud code, specifically with running simple curl tests.

The initial parse-server installation includes a sample main.js file that contains a hello world function

My own parse installation is hosted at '/parse' so URLs use this as the root

The following is a simple request test

 curl -X POST \   
 -H "X-Parse-Application-Id: myAppId" \   
 -H "X-Parse-REST-API-Key:myRESTKey" \   
 -H "Content-Type: application/json" \   
 -d '{}' \  
 http://localhost:1337/parse/1/functions/hello

The response I get is

Cannot POST /parse/1/functions/hello

Which I take to be curls perfunctory statement that it cannot find a suitable POST endpoint

What is going wrong here? I have simply changed the sample curl example from Parse.com's documentation on using cloud-code to use my parse-server installation details

解决方案

The answer is that unlike with Parses hosted solution the API version path is not something hosted with parse-server

if you host parse at e.g.: /parse as I have done above, then that is the relative URL where the functions API is available. So simply remove the /1/ from the path

The same curl command works with this URL

http://localhost:1337/parse/functions/hello

eg:

curl -X POST \   
-H "X-Parse-Application-Id: myAppId" \   
-H "X-Parse-REST-API-Key:myRESTKey" \   
-H "Content-Type: application/json" \   
-d '{}' \  
http://localhost:1337/parse/functions/hello

这篇关于解析服务器云代码功能“无法POST”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆