NelmioApiDoc Bad Request 400 with RestApi - json

The Nelmio is working perfectly in my project but I get an error 400 Bad Request
when I want to insert a date in my Nelmio !!
The type used is Date.

you send something like
transaction[dateP]=value
but form required something like this
transaction[dateP][year]=value&transaction[dateP][month]=value&transaction[dateP][data]=value
So split your value into 3 parameters or you can change widget option of dateP field to single_text to solve the problem.

I guess that all the transaction details are not needed as parameters which have to be defined in the URL of you request.
In case of being data, you will have to specify it like this {"transaction":{}} in the content box on you right.

Related

Wavefront Alerting when no data sent

I have wavefront alerts set up with the following alert condition:
ts(mytimeseries)<20000
Recently the datasource stopped sending data to wavefront but I did not receive an alert. I cannot figure out why this did not alert. Do I need to set up a separate alert for when data is not sent. Thanks
Yes in scenarios where there is no data sent you explicitly need to define the condition for that. Well the best approach is to create a new availability alert but still if you want to manipulate the same condition you can do something like below
default( 20001 ,ts(mytimeseries))<20000
In case there is no data found it will exceed your limit and will raise the alert

Getting the value of a particular cell with AJAX

My goal is very simple and I would guess it is a very common goal among web developers.
I am creating a Rails (5.1) application, and I simply want to use AJAX to get the value of a specific cell in a specific row of a specific table in my database (later I am going to use that value to highlight some text on the current page in the user's browser).
I have not been able to find any documentation online explaining how to do this. As I said, it seems like a basic task to ask of jquery and ajax, so I'm confused as to why I'm having so much trouble figuring it out.
For concreteness, say I have a table called 'animals', and I want to get the value of the column 'species' for the animal with 'id' = 99.
How can I construct an AJAX call to query the database for the value of 'species' for the 'animal' with 'id' = 99 .
Though some DBs provide a REST API, what we commonly do is define a route in the app to pull and return data from the DB.
So:
Add a route
Add a controller/action for that route
In that action, fetch the data from the DB and render it in your preferred format
On the client-side, make the AJAX call to that controller/action and do something with the response.

Phone number validation in angularjs

I am trying to validate phone number for the below condition,
If all 10 digits are of same number,it should display an error message.
If it starts with 1, it should display an error message.
Please share your suggestion if you have come across such scenario.
Without example code, it will be hard for us to see what you are trying to do - and if you have even attempted at solving it yourself.
But oh well, there are multiple ways of doing this, what you want is serverside validation - as you NEVER want to validate on the users end.
How can you limit the value from input using AngularJS?
Adding a listener on a model in angularjs With this one (And I 'THINK' this is what you want), you can update 'something' according to what is being input into the text area.

GET and POST values in the same link

I want something like this:
link
GET and 2x POST in hyperlink. How can I do that? Nothing wants to work
I have a GET array in PHP and I want to generate a link which leads to the correct url to give me those GET variables.
You can't have 2 GET variables with the same name. You can arrange them into an array as follows:
link
Just for clarification, this is still a GET request, links cannot normally produce a POST request, nor you should try to achieve that not-normally.
EDIT: To answer OP's calrification.
If you have a $_GET array, and you want to generate a link to get you there, you can use http_build_query()
I don't think you understand what GET and POST means in the HTTP world. Any items you put on a query string of a URL are GET parameters, you can't have 2 with the same name. POST parameters are sent as a part of the request, not as a query string on the URL.
GET and POST are http operations.
Sending values by using the ? as a separator in the url is different but related. eg:
foo.com/page.php?val1=1&val2=2
The values are called Query String values.
For GET operations, values are sent as a query string values. For POST operations, the values are sent in the body of the POST request. This is why POST must be used when a lot of data is being sent to the server. (Query strings have a maximum length, HTTP requests do not.)
You can do a POST operation to a url that includes query string values. This is more common with Ajax requests but can be done in a form as well. Just set the action url to something like index.php?val1=1&val2=2 the form's (additional) values will be sent as the http body. Remember to set method="post" in the form.
Note that you will need to create the query string yourself in this example, including escaping it properly.
Repeating value names in the query string values
Usually this causes both values to be sent, but the server overwrites the variable and ends up only presenting the last one to the client software.
So if you use a url such as
<a href="http://localhost/index.php?get=abc&post=cde&post=efg">
// It will be decoded by php and most server-side frameworks as
set get to abc
set post to cde
set post to efg
Result: 2 variables, get and post
There is nothing in the HTTP standard that says you can't send two query string params with the same name. However, you won't be able to use $_GET to retrieve these values; $_GET will pick up the last one. Instead, you'll have to manually parse $_SERVER['QUERY_STRING']. It's not that hard and I've done it a number of times when PHP has to handle a URL pattern generated by a third-party tool. If you're feeling really fancy you can have your query-string parse routine generate a $_GET member as an array if more than one instance of that member is encountered.

Box API: Get_managed_users returning all users

Using the Box 1.0 REST API, I am trying to work with the functions in SOAP UI.
The API doc for get_managed_users with user_id=12345 (internal id retrieved with get_user_id call correctly) is returning all the users. The docs say that would be the case if you do not specify a user_id value. But my full command is: (Token and API key changed to protect the clueless)
https://www.box.com/api/1.0/rest?user_id=27360&auth_token=blahbalhblah1234&action=get_managed_users&api_key=someKeyYouShouldNotSee
Now I could work with the complete result list, but that won't scale as we get thousands of users into the system.
I can make a call with edit_managed_user, using the same user_id value and the change is reflected in the UI, and in the next get_managed_users call. Thus I do have the correct user_id value, I would so assume.
I tried testuser#gmail.com as the user_id value as well, and get the entire list back. This leads me to believe that somehow I am sending user_id wrong, but I just do not see it.
Any hints? Why, with what seems like a valid user_id value is it acting like it is absent or incorrect?
Most likely you have either called this method with an invalid user_id, or one that is not in your set of managed users. Can you double check that the user comes back in your list of already managed users?