RESTFUL API : new Iron Router version this.request.body not working anymore - iron-router

I had my API fully functional and everything was working like a charm but with the last updates of Iron Router (Meteor update could impact?) my command
this.request.body
doesn't render nothing when I have a POST call on my API (all calls work good and I have no problem with GET this.params), I took a look at the docs and I don't see nothing talking about this, does anyone have an idea?
Thanks for your help =)
PS : I tried to replace it (without success obviously) by :
this.params.query.body
this.request.query.body
When I try to do a JSON.stringify on this.request it is empty so I guess it has been moved somewhere...

As asked here https://github.com/EventedMind/iron-router/issues/1003, just add:
Router.onBeforeAction(Iron.Router.bodyParser.urlencoded({extended: false}))
in your Meteor.startup

Related

Deploying actions on google webhook on glitch

I want to deploy this example on glitch. I've added package.js and index.js to my glitch project and built successfully.
However, the code is missing a section to listen for HTTPS requests. In most node.js/express webapps, there is code to indicate which paths trigger which functions, but this is missing from the example. Can you explain to me how it should work and why that part is missing from this example?
It's not clear what do you mean by "the code is missing a section to listen" as the only main feature of index.js is to listen to requests and return information.
I suggest you check index.js and make sure that you getting requests to your end point on glitch.
Also, it would be helpful if you can share your glitch project over here at SO so we could see what you are doing.
Btw, you might want to double check that you have all the packages
I also created this simple example on Glitch - It's returning the current bitcoin price. Feel free to remix it and use the code there for your own action.
Good luck!
The part that "listens to requests" is
// The Entry point to all our actions
const actionMap = new Map();
actionMap.set(ACTION_PRICE, priceHandler);
actionMap.set(ACTION_TOTAL, totalHandler);
actionMap.set(ACTION_BLOCK, blockCountHandler);
actionMap.set(ACTION_MARKET, marketCaptHandler);
actionMap.set(ACTION_INTERVAL, intervalHandler);
assistant.handleRequest(actionMap);
where each ACTION is an action(in an intent) in Dialogflow and the handler is the corresponding function in your code.
I'd recommend you take a look at
https://codelabs.developers.google.com/codelabs/assistant-codelab/index.html?index=..%2F..%2Findex#0
If you want a good example of an assistant app, though this uses firebase instead of glitch.

How to get All test cycle from ZAPI rest call

I am trying to use this API to manage my automation test cases in Jira-Zephyr.
I am trying to get all the test cycle from my project, So as per the ZAPI technical doc I used
http://localhost:8080/jira/rest/zapi/latest/cycle?projectId=10002&versionId=10100
But it is not working, It says that it is a dead link.
I googled for search all the issue from project, So I got the below one
http://localhost:8080/rest/api/2/search?jql=project=10002
and it is working fine for me.
So as per this link I changed the above link
It is also not working.
How I can Find out all the test cycle present in the project?
this works for me with a local install of Jira + zapi, zephry add-ons
http://localhost:8080/rest/zapi/latest/cycle?projectId={{projectId}}&versionId={{versionId}}
try like this, def clientTestID = new RESTClient("https://XXXXXXXXXX.net/rest/zapi/latest/zql/executeSearch?maxRecords=9999&zqlQuery=cycleId=XXXXX")
This will work for sure if headers are properly defined

How do relative URLs work in Sinatra?

I am hosting my Sinatra application using Apache with Passenger. It's hosted within a subfolder -- meaning, my main site is example.com, my application is at example.com/popcorn.
So I have a get '/' route, and that works fine. The problem is that my view includes a HTML form that makes a post request to upload, and the post '/upload' route isn't handling it. Instead of example.com/popcorn/upload, it's trying to get example.com/upload.
So I figure okay, not the ideal solution, but for now I'll hardcode the form action URL. But that doesn't work either -- making the action popcorn/upload fails too. This is where I get a little baffled, and my Google-fu was weak, I couldn't find help there.
Maybe I could have some kind of Apache rewrite rule, but is that the correct solution? Am I missing something? I would really appreciate a tip here because it feels like I've messed up something very simple and it's really bugging me.
You probably want the url helper method. That takes into account where the app is mounted on the server:
url('/upload')
The above code will evaluate to something like this:
http://example.com/popcord/upload
Inside your app you shouldn’t need to change anything, this will be routed to the existing post '/upload' handler.

Calling webapi method gives 404

I don't understand this.
I have a webapi project setup locally on my own server, that works. I can go to http://mydomain.com/Api/Method and get my expected result no problem, works across 3g and everything too.
Then I have a website hosted somewhere else, in which tried to use this webapi method and this works fine when I test it locally, but as soon as I publish to the web and try it from there it fails with a 404 error?
I've tried both post and get methods and made sure the api method accepted both verbs.
I've tried calling the method both with javascript ajax and from within an MVC controller using a WebRequest.
I just don't understand why it works fine from any webbrowser, but I can't get it to work even with a programmatic WebRequest, shouldn't it be the same?
Nevermind.
Apparently, it was as simple as just setting an accept header with a value of "text/html" (in my case).
I spent way too much time figuring that out. Thanks #I4V for leading me in the right direction.

node-mongodb-native example code vs docs code? which to use?

I just wrote my first nodejs program using the node-mongodb-native driver. I used the documentation code from the github page, i.e.:
var mongodb = require("mongodb"),
mongoserver = new mongodb.Server('localhost', 6574),
dbConnector = new mongodb.Db('test', mongoserver);
dbConnector.open(function(err, db){
if(err)
console.log('oh shit! connector.open error!');
else{
...
However, upon looking at some example code on the github page, I discovered that the set up code looks very different from what I used. Does anybody know if there's any real difference between the different methods? I'm completely new to all this stuff and can't really tell if there's any reason to use one over the other. The code I wrote seems to run fine, but if the creator of the driver is using different code, I figured it would be worth checking if there are any reasons for that.
Thanks in advance for any replies!
Sami
Hi I'm the creator and no there is no particular reason you can't use your style. As when it comes to docs I usually tell people to start with the integration tests as there are many examples on how to do stuff. Unfortunately due to having a fulltime job the docs are not kept up to date at the pace I would like to.
I'm hoping to do something with that come late september but right now I'm trying to just get the driver up to the expected features of mongodb including making it work with 1.9.X and higher.
I'll accept any docs pull requests happily as the more the community help me the more it helps itself :)