Domanda

I am trying the Monaca Push Notification API tutorial (http://monaca.mobi/en/blog/archives/265) to send push notification to my iPhone using curl from my command prompt.

If I use this:

curl --insecure https://cloud.monaca.mobi/manage/json-rpc/##### --data '{"jsonrpc": "2.0", "id": 1, "method": "Push.send", "params": { "pushProjectId": "#####", "platform": "ios", "target": "debugger", "buildType": "debug", "message": "manage sample" , "json" : "{ \"url\" : \"http://www.google.co.jp\" }", "deviceIdList": ["#####"] } }' --header 'X-Monaca-Backend-Management-API-Key: #####'  

I get these errors:

curl: (6) Could not resolve host: id
curl: (6) Could not resolve host: 1,
curl: (6) Could not resolve host: method
curl: (6) Could not resolve host: Push.send,
curl: (6) Could not resolve host: params
curl: (3) [globbing] unmatched brace in colum
curl: (6) Could not resolve host: pushProject
curl: (6) Could not resolve host: ###
curl: (6) Could not resolve host: platform
curl: (6) Could not resolve host: ios,
curl: (6) Could not resolve host: target
curl: (6) Could not resolve host: debugger,
curl: (6) Could not resolve host: buildType
curl: (6) Could not resolve host: debug,
curl: (6) Could not resolve host: message
curl: (6) Could not resolve host: manage samp
curl: (6) Could not resolve host: ,
curl: (6) Could not resolve host: json
curl: (7) Failed connect to :80; No error   

Then I tried saving the data to senddata.json file

{
    "jsonrpc": "2.0", 
    "method": "Push.send", 
    "params": { 
        "pushProjectId": "#####", 
        "platform": "ios", 
        "target": "debugger", 
        "buildType": "debug", 
        "message": "manage sample" , 
        "json" : "{ \"url\" : \"http://www.google.co.jp\" }", 
        "deviceIdList": [ "#####" ] 
     },
     "id": 1
}

and use this command to call:

curl --insecure https://cloud.monaca.mobi/manage/##### --data C:\myfilepath\senddata.json -H "Content-Type: application/json" --header "X-Monaca-Backend-Management-API-Key: #####"  

But it also returns this error:

{"jsonrpc":"2.0","id":null,"error":{"code":-32700,"message":"Parse error"}}
È stato utile?

Soluzione

The problem is solved. It seems that running curl commands in command prompt on windows has some problems which returns errors such as curl: (3) [globbing] unmatched brace in colum

If you are facing the same problem, follow/recheck the following steps:

  1. Check whether you installed curl properly on Windows (http://guides.instructure.com/s/2204/m/4214/l/83393-how-do-i-install-and-use-curl-on-a-windows-machine)
  2. Install and use cygwin terminal
    (http://hariniachala.blogspot.com/2012/08/running-curl-commands-in-command-prompt.html)
    since the DOS environment doesn't seem to like single quotes. Any example that uses single quotes to surround values is invalid on windows. The single quotes must be replaced with double quotes.

Hope this helps.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top