Menu
  • HOME
  • TAGS

Aglio does not allow parameters in the body to be defined as parameters

Tag: rest,markdown,apiblueprint,aglio

Aglio, an API Blueprint renderer, does not allow parameters in the body of a request to be included in the parameters section of the the Endpoint specification. It throws parse warning as follows:

parameter '<some_parameter>' not specified in '<some_description>' its '<some_URI_template>' URI template (warning code 8)

A sample Markdown which would replicate this warning is:

## Journey creation [/v1/journeys/{origin}]

### Create journey [POST]
Create a new journey

+ Parameters
    + origin (required) ... origin location of journey
    + destination (required) ... destination location of journey

+ Request
    + Headers

                Accept: application/json
                Authorization: Basic <BASIC_AUTH_TOKEN>

    + Body

                {
                     "destination" : "some_other_place"
                }


+ Response 200 (application/json)

    + Body

            {
            "origin" : "some_place",
            "destination" : "some_other_place",
            "journey_state" : "Not_Started",
            "timestamp" : "<dateuuid>",
            }

The rendered does not like 'destination' to be a parameter, since it is not in the URI template.

My question is, is this a drawback of the tool, or is it an API Blueprint specificaton? Also, maybe, is this definition of a REST endpoint not per standards?

Best How To :

The correct way to specify message body attributes is using the new MSON attribute syntax, which currently does not render in Aglio (but I am working on adding it).

### Create journey [POST]
Create a new journey

+ Parameters
    + origin (required) - origin location of journey

+ Attributes
    + destination (required) - destination location of journey

+ Request
    + Headers

                Accept: application/json
                Authorization: Basic 

    + Body

                {
                     "destination" : "some_other_place"
                }

In the near future Aglio will render extra information for the attributes.

(CORS) How does the browser know when to do a pre-flight request

javascript,rest,dom,xmlhttprequest,cors

The browser will send a preflight request if: You add custom headers to your request You use a method other than GET, HEAD or POST You use POST with an unusual Content-Type. More details here: HTTP access control (CORS), Preflighted requests...

Intercepting login calls with Spring-Security-Rest plugin in Grails

rest,grails,spring-security

Yes, you can provide a custom bean that implements the RestAuthenticationSuccessHandler. Take a look at the API documentation for the class to see what you need to implement. Then it's as simple as overriding the bean in your application context: // Resources.groovy restAuthenticationSuccessHandler(MyCustomRestAuthenticationSuccessHandler) { renderer = ref('accessTokenJsonRenderer') } It might...

Default/Constant values for POST/PUT arguments with Retrofit

java,rest,retrofit

Maybe one option would be to send an object, which encapsulates all your values, instead of all string values separately? The object would implement your default values. For example, you could create a class: public class CreateObject { private String type = "constant"; private String value; private String otherValue; public...

In simple RESTful design, does PATCH imply mapping to CRUD's (ORM's) “update” and PUT to “destroy”+“create” (to replace a resource)?

database,rest,http,orm,crud

Well, Both the actions actually means update, where PUT is full update and PATCH is partial update. In case of PUT you already know the identifier of the resource and the resource already exists, so it is not a create and delete action per se. Infact, you can make do...

Not able to create a WCF RestFul Service's client

asp.net,web-services,wcf,rest

I found the answer myself. In my service I had not declared an endpoint for met data exchange due to which when I was trying to add the reference of the service to the client the required app.config was not being generated. Adding the end point for metadata exchange solved...

remote data fetching inside model object in objective c using AFNetworking

ios,objective-c,rest,model-view-controller,afnetworking-2

I dont have anything to say about your MVC(Model–view–controller) correct? I just want to add something that may be useful approach avoiding unwanted crashes.. First is under [[MyAPI sharedInstance] POST:@"auth/" parameters:params success:^(NSURLSessionDataTask *task, id responseObject) { if([responseObject objectForKey:@"id"]) { [[NSUserDefaults standardUserDefaults] setObject:(NSDictionary*) responseObject forKey:USER_KEY]; [[NSUserDefaults standardUserDefaults] synchronize]; result = [responseObject...

REST Jersey server JAX-RS 500 Internal Server Error

java,rest,jersey,jax-rs

IllegalAnnotationException: Class has two properties of the same name "list" Look at your two model classes XmlMessageBean and ResponseList. Do you see any difference? The main difference (and the cause for the error), is the @XmlAccessorType(XmlAccessType.FIELD) annotation (or lack there of). JAXB by default will look for the public...

Unable to upload file to Sharepoint @ Office 365 via REST

javascript,ajax,rest,sharepoint,office365

To me it just seems a bit light, visit this link https://msdn.microsoft.com/en-us/library/office/dn769086.aspx on technet, and compare your upload function to this: // Add the file to the file collection in the Shared Documents folder. function addFileToFolder(arrayBuffer) { // Get the file name from the file input control on the page....

How to send a JsonObject in JerseyClient POST call?

java,json,rest,jersey,jersey-client

You should add (de)serializators for JSONObject - jackson-datatype-json-org <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-json-org</artifactId> <version>2.4.0</version> </dependency> And register module: ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JsonOrgModule()); ...

Spring service and Spring web app in one

spring,web-services,rest,spring-mvc,web

yes that is possible to combine with web-app for example your controller package into your restful controller also work that is possible to crud operation via restful web service....

use markdown module in Angular.js , it doesn't turn to the html element

angularjs,markdown

Use ng-bind-html instead of ng-bind.

How to specify supported http operation for a resource in json-ld?

rest,http-method,json-ld

No, you can't specify it in the context. What you can do, however, is to bind an operation to a property in a Hydra ApiDocumentation (example 10 in the spec) and reference it via an HTTP Link header.

@RestController throws HTTP Status 406

java,spring,rest,maven

The issue is with the dependencies that you have in pom.xml file. In Spring 4.1.* version the pom.xml dependency for Jackson libraries should include these: <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.4.1</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.4.1.1</version> </dependency> You...

Spring Boot REST display id of parent only in a JSON response

json,spring,rest,spring-boot

Basically returning entities directly from endpoints isn't a good idea. You make very tight coupling between DB model and responses. Instead, implement a POJO class that will be equivalent of the HTTP response you sent. This POJO will have all ChildEntity fields and parentId only and will be constructed in...

REST API with token based authentication

angularjs,codeigniter,api,rest,token

You can use an API key, however - as you wrote - it's pure protection and easily accessible value - potential abuser just needs to view the source or investigate the queries. In general REST APIs are secured with tokens. At the beginning of the session (not in traditional meaning...

Spring Data Rest executes query but returns 500 internal Server Error

java,spring,rest,spring-boot,spring-data-rest

Hum... This is strange but I found this question and added a controller to call the method and it worked like a charm... Obv this is not a fix, but it is a good workaround... EDIT: The error happens because it is expecting an entity, so all I had to...

REST api : correctly ask for an action

api,rest,endpoint

Try to separate API from your application logic. From API you GET the quote and API from now on shouldn't care what you do with that data. The same with marking quotes as favorites. It's your application's and user db's problem how to mark something. Again, API should care only...

Link to another resource in a REST API: by its ID, or by its URL?

json,api,rest,api-design,hateoas

DO include absolute entity URIs in your responses (such as /customers/12 or even http://www.example.com/customers/12). DO NOT include just an entity's ID (such as 12) in a response, because that way you're forcing clients to put together resource URIs themselves. In order to do that, they would need to have prior...

Do we HAVE to generate and use client libraries to use Google App Engine's Endpoints?

ios,swift,rest,google-app-engine,google-cloud-endpoints

Yes, it's totally possible to access endpoints via HTTP requests. The client libraries just help you to generate those requests without having to know the exact URLs. The biggest part where the client libraries help you is for authentication, but if you authenticate with Google and get an access token...

Is JSON better than XML? Which one is more secured? [duplicate]

android,json,xml,web-services,rest

In compare to JSON and XML , there is no difference in security but JSON is much faster than XML thats why we prefer JSOn over XMl...But if you see from security point of view than you can go for SOAP

Laravel: Retrieve polymorphic attributes efficiently

rest,laravel,polymorphism,eloquent

You might be almost there. Your getAvatarAttribute() is way too complicated, indeed. You could try to do something like: /** we hide the relation from the json */ protected $hidden = ['avatar']; /** we append the url of the avatar to the json */ protected $appends = ['avatar_url']; /** *...

Retrofit updating class PUT error code 301

android,rest,retrofit,put

Finally I solved it. The problem was that we had two different Client objects and the one that you fetch is the one that you must change and use it to upload with PUT. I hope that this help somebody....

Spring MVC - How to return simple String as JSON in Rest Controller

java,json,spring,rest,spring-mvc

A String as JSON? Proper JSON needs a key and a value { key: value } So either return text/plain (as in Return only string message from Spring MVC 3 Controller) OR wrap your String is some object public class StringResponse { private String response; public StringResponse(String s) { this.response...

How to expose existing REST API through Azure Service Bus (or through something else)

rest,azure,azureservicebus

If you want to access an On-Premise service from the Azure service/websites what you need is a Hybrid Connection. For that you will need a BizTalk service to redirect the trafic to your on-prem service. Here are the steps to how to setup a Hybrid connection: https://azure.microsoft.com/en-us/documentation/articles/web-sites-hybrid-connection-get-started/...

Not able to hit 2nd services with generated Token

c#,web-services,rest,soap,drupal-services

Finally i figured out what was the issue i was creating new cookie container for both the request request.CookieContainer = new CookieContainer(); thus server was unable to authenticate Error was resolved by using this code CookieContainer cookieJar = new CookieContainer(); private void CreateObject() { try { string abc = "";...

AngularJS $resource Custom Action for Requesting a Password Reset

angularjs,rest,ngresource,angularjs-1.3

yes, looks a little bit weird. Instead of GET I will use POST request to reset the password and pass the email param in request body

Sencha/Extjs rest call with all parameters

json,rest,extjs,sencha-touch

You need to specify a writer config on your proxy with writeAllFields: true. By default it's false, and the default writer itself is just {type: 'json'}.

How to make Jersey Unit test for Post method

java,rest,junit,jersey,jax-rs

@Path("hello") public static class HelloResource { @POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public String doPost(Map<String, String> data) { return "Hello " + data.get("name") + "!"; } } @Override protected Application configure() { return new ResourceConfig(HelloResource.class); } @Test public void testPost() { Map<String, String> data = new HashMap<String, String>(); data.put("name", "popovitsj"); final String hello...

Using .update with nested Serializer to post Image

django,rest,django-models,django-rest-framework,imagefield

As noted in the docs, .update() doesn't call the model .save() or fire the post_save/pre_save signals for each matched model. It almost directly translates into a SQL UPDATE statement. https://docs.djangoproject.com/en/1.8/ref/models/querysets/#update Finally, realize that update() does an update at the SQL level and, thus, does not call any save() methods on...

.NET web service gets null object

c#,.net,ajax,web-services,rest

Possibly the mistake in this line var data = '{ "c:":{"Id": "1", "Name": "myname"}'; should be var data = '{ "c":{"Id": "1", "Name": "myname"}'; ...

No module named http_client error when trying to run django with django rest framework

python,django,rest

It looks like you are hitting issue 2969. It should work if you upgrade from Django 1.6 to 1.6.11. However, please note that 1.6 is now end of life and does not receive security fixes, so ideally you should upgrade to 1.7, or even better, the new 1.8 LTS.

Springboot REST application should accept and produce both XML and JSON

java,xml,rest,jackson,spring-boot

Try to add a @XmlRootElement(name="myRootTag") JAXB annotation with the tag you use as the root tag to the class MatchRequest. I have had similar issues when using both XML and JSON as transport format in a REST request, but using moxy instead of Jackson. In any case, proper JAXB annotations...

Jersey JUnit Test: @WebListener ServletContextListener not invoked

java,rest,junit,jersey,jax-rs

The JerseyTest needs to be set up to run in a Servlet environment, as mentioned here. Here are the good parts: @Override protected TestContainerFactory getTestContainerFactory() { return new GrizzlyWebTestContainerFactory(); } @Override protected DeploymentContext configureDeployment() { ResourceConfig config = new ResourceConfig(SessionResource.class); return ServletDeploymentContext.forServlet(new ServletContainer(config)) .addListener(AppContextListener.class) .build(); } See the APIs for...

What's the best way to map objects into ember model from REST Web API?

json,rest,ember.js,asp.net-web-api,ember-data

I think this should fix your problem: export default DS.RESTSerializer.extend({ primaryKey: 'inventory_id' }); With this parameter Ember Data will map inventory_id to it's id parameter....

How to manipulate local files with webdav

javascript,jquery,rest,file-upload,webdav

So I figured it out a while ago. I was thinking the wrong way. It is not the client that will do anything it will be the server. So the client can make a regular http call and just change the "type" string from get or what ever to MKCOL...

Consuming and exposing webservices in one project (.NET)

.net,web-services,rest,soap

If you are trying to enrich the data from one source and combine that with information from another source, I think this is a decent solution. I think it is better to have one single point to talk to (your REST service), than to have two in your application and...

RESTful routing best practice when referencing current_user from route?

ruby-on-rails,rest

I would've added special routes for current user profile actions, in this case you don't have to check anything. Just load and display the data of current user. For example: /my-profile/edit /my-profile/newsfeed It's not that RESTful but you don't have to put extra checks keeping your code clean. If you...

Correct workflow for presence subcription for day/night

rest,lync,ucwa,skype-for-business

If you don't do reportMyActivity your Application will be drained, because assumed inactive. I think you only have two options then: Keep doing reportMyActivity regurarly also at night, you'll just stop extending presence subscription. Very likely you'll have to manage access token expiration too, which is normally 8 hours valid...

REST-API Different Content-Type on Error Response

java,json,api,rest,spring-mvc

User should always specify what content it's expecting with Accept header. It's you job to return the error that was thrown/caught on the server side in the format that was specified in Accept header. In spring as far as I know it could be achieved with a special mapper. Below...

Mailchimp Ecommerce360 Javascript Implementation

javascript,rest,e-commerce,mailchimp

If you mean from client-side Javascript, this isn't possible because the MailChimp API doesn't support CORS and (in most cases) this is a huge security issue. You'll need to communicate with Javascript back to your own servers and have those machines make the requisite API calls.

Trying to write a unit test for file upload to a django Restless API

python,django,rest,file-upload,request

I tried to fix this but in the end it was quicker and easier to switch to the Django-REST framework. The docs are so much better for Djano-REST that it was trivial to set it up and build tests. There seem to be no time savings to be had with...

Can't save json data to variable (or cache) with angularjs $http.get

json,angularjs,web-services,rest

$http.get is asynchronous. When cache.get or return result are executed, HTTP request has not completed yet. How are you going to use that data? Display in UI? E.g. try the following: // Some View <div>{{myData}}</div> // Controller app.controller('MyController', function ($scope) { $http.get('yoururl').success(function (data) { $scope.myData = data; }); }); You...

How to avoid abusive use of REST endpoint [closed]

java,javascript,rest

The answer is simple: Don't use the UI as the definitive state for your users. Stack Overflow is actually a great example of this. When I voted up your question, the UI only updated after the REST call to the backend completed successfully with no errors. So you should be...

Adding authorization to routes

ruby-on-rails,rest,routes,authorization

Do you know the gems rolify and CanCanCan? I think they can help you manage authorizations on resources in a single place instead of having to do it in every controller....

Remove resource wrapper from CakePHP REST API JSON

rest,cakephp,cakephp-2.2

Use the Hash utility to rewrite the results returned before setting the data for the View:- class LeadPostsController extends AppController { public $components = array('RequestHandler'); public function index() { $records = $this->LeadPost->find('all', ['limit' => 20]); $this->set(array( 'leadposts' => Hash::extract($records, '{n}.LeadPost'), '_serialize' => 'leadposts' )); } } Here Hash::extract($records, '{n}.LeadPost') will...

How to respond in Middleware Slim PHP Framework

php,rest,authentication,middleware,slim

You cannot use halt in middleware: http://stackoverflow.com/a/10201595/2970321 Halt should only be invoked within the context of a route callback. Instead, you could manually generate a 400 response using PHP's header along with exit: header("HTTP/1.1 400 Access denied"); exit; Alternatively, you could define a new type of Exception: class AuthException extends...

Unable to select values from the select list

javascript,jquery,rest

Here is the working fiddle: https://jsfiddle.net/64djszjf/14/ If you take a look at the source js file: https://aui-cdn.atlassian.com/aui-adg/5.8.13/js/aui-experimental.js, there are few lines that sets unselectable class: populateResults: function(container, results, query) { var populate, id=this.opts.id; populate=function(results, container, depth) { var i, l, result, selectable, disabled, compound, node, label, innerContainer, formatted; results =...

How can I get json objects without the object number?

javascript,jquery,json,rest

Create an object. Loop over the array Get the name of each member of the array Copy each member into the object using a property name that is the same as the name you just got Then just use the object instead of the array. You might want to...

Stuck with nested serializer using Django Rest Framework and default user

django,api,rest,django-rest-framework,serializer

By default DRF will look at an attribute on the User model named after the serializer's field (member here). However the related name is profile. This can be worked around by passing the source="profile" to your MemberProfileSerializer....

Ruby on Rails - Help Adding Badges to Application

ruby-on-rails,ruby,rest,activerecord,one-to-many

Take a look at merit gem. Even if you want to develop your own badge system from scratch this gem contains plenty of nice solutions you can use. https://github.com/merit-gem/merit