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....
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.
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...
At the time of this posting, the REST API is not yet complete. A much more detailed document exists, though it's still not comprehensive. It is linked to in the following email from the user mailing list (which you might want to consider joining): http://www.mail-archive.com/user%40nutch.apache.org/msg13652.html But to answer your question...
It sounds like the Result is actually a textual representation of the byte array, rather than actually containing an array of bytes. Have you had a look at the raw JSON to see what is in Result? If it's actually textual (either hexadecimal or base64) you will need to simply...
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...
I think you could do something like: def findAllIssuesByRest(componentKey: String): Future[Seq[Issue]] = // fetch first page fetchIssuePage(componentKey, 0).flatMap { json => val nbPages = extractPagingInfo(json).pages // get the total number of pages val firstIssues = extractIssues(json) // the first issues // get the other pages Future.sequence((1 to nbPages).map(page => fetchIssuePage(componentKey,...
rest,annotations,websphere-liberty,apache-wink
I am afraid you can only define this via web.xml file. This is also the way WINk supported. In your case, even if you have @ApplicationPath("rest") defined,you can also have a web.xml.
A Websocket connection starts with a HTTP handshake. On the handshake you also receive cookies (e.g. the session ID cookie) so you get access to the HTTP session. From the JSR 356 Java API for WebSocket spec: Because websocket connections are initiated with an http request, there is an association...
The /Token endpoint already provides all the functionality you need in order to use [Authorize] on your WebAPI methods. The general process to make this work would be something like the following: Client establishes a POST request to http://somesite.com/Token. The Content-Type header should contain x-www-form-urlencoded. The payload body should include...
This was a minor bug in the Parse REST API. They fixed it within 48 hours after reporting.
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...
python,rest,flask,raspberry-pi
The only way to preserve information across requests is to store it somewhere and retrieve it on the next request. Or recreate the object (including state) using parameters passed from the client. For your case, since you'll only be using one Player at any given time, you can make it...
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...
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...
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...
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...
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...
django,api,rest,django-rest-framework
UPDATE is possible via 2 requests: PUT and PATCH PUT updates all the fields of the object on which the operation is to be performed. It basically iterates over all the fields and updates them one by one. Thus, if a required field is not found in the supplied data,...
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....
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()); ...
Seeing from your previous question, you seem to missing a provider for JSON/POJO support. You can see this answer for all the jars and dependencies you need to add to your project. Note: The linked answer shows 2.17 jars for Jersey, but you are using 2.18. The answer also provides...
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...
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...
c#,json,entity-framework,wcf,rest
Probably the most simple approach would be to wrap your results into generic response objects [DataContract] public class Response<T> { [DataMember] public T Result { get; set; } [DataMember] public int Status { get; set; } } // then your declaration Response<List<User>> serverResponse = Response<List<User>>(); // on success serverResponse.Result =...
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...
javascript,rest,automated-tests,web-api-testing,frisby.js
I fixed using .after() instead .afterJSON().
rest,xamarin,servicestack,restful-authentication,servicestack-auth
The issue is because you're using the same Session Cookies with a shared ServiceClient instance which ends up referencing the same Authenticated Users Session. ServiceStack Sessions are only based on the session identifiers (ss-id/ss-pid) specified by the clients cookies, if you use the same cookies you will be referencing the...
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'}.
if you allowed to use external PHP libraries; I'd like to suggest this method: https://github.com/php-curl-class/php-curl-class // Requests in parallel with callback functions. $multi_curl = new MultiCurl(); $multi_curl->success(function($instance) { echo 'call to "' . $instance->url . '" was successful.' . "\n"; echo 'response: ' . $instance->response . "\n"; }); $multi_curl->error(function($instance) {...
rest,restful-architecture,apiblueprint,apiary.io,apiary
Nothing is wrong with your blueprint. I am afraid the Apiary Mock is rather simplistic and always returns the first response specified (content-negotiation permitting) as default. See "Invoking non-default responses" at Apiary http://support.apiary.io/knowledgebase/articles/117119-handling-multiple-actions-on-a-single-resource to see how to invoke (on demand) another response. Also note there is a proposed syntax in...
I got my answer from the SuiteCRM forum. We could get the relationships by using the following parameters: $get_franchise_lead_parameters = array( 'session'=>$sessionID, 'module_name'=>'Leads', 'module_id'=>$lead, 'link_field_name'=>'name of the linked field', 'related_module_link_name_to_fields_array' => array(), 'related_fields' => array( 'id', 'name', ), 'deleted' => '0', ); ...
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.
inf3rnos comment, even its short is the correct answer: You don't have to allow every HTTP method a.k.a verbs (see list of the standard ones or longer list here) on an entity. I would go even further: I think I never have seen any real life API with all HTTP...
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...
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.
asp.net-mvc,rest,asp.net-web-api,asp.net-routing
The article provides a sample on how to configure routing. These last two samples are just for illustrative purposes, it is more like pseudo-code, not a working code. If you are just starting with C# these last code samples are confusing. The errors that you are getting clearly describe what...
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...
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...
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....
In Jersey 1.x you can supply your client instance with a filter dealing with authentication: Client client = Client.create() client.addFilter(new HTTPBasicAuthFilter("neo4j","<mypwd>")); // <-- that's it! WebResource resource = client.resource( "http://localhost:7474/db/data/transaction/commit" ); ClientResponse response = resource.accept( MediaType.APPLICATION_JSON ) .type( MediaType.APPLICATION_JSON ) .post( ClientResponse.class, someStringContainingJsonPayload); ...
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....
There are few ways to do this the one way of doing it is to make the props_load a private static member of the class and call it like this public class SendEmailUtility { private static Properties props; private static Properties getProperties() { if (props == null) { File configDir...
@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...
javascript,rest,authentication,backbone.js,login
You might be missing the expires= part of the cookie. You can also add an expiry date (in UTC time). By default, the cookie is deleted when the browser is closed: document.cookie="username=John Doe; expires=Thu, 18 Dec 2013 12:00:00 UTC"; http://www.w3schools.com/js/js_cookies.asp...
rest,woocommerce,payment-gateway
As helgatheviking concurred, there currently isn't a way to process payment of an order with the WooCommerce REST API. I ended up writing a hook into the the woocommerce_api_create_order filter that immediately processes the order for payment when the order is created. If the processing fails, then the errors are...
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...
According to this article: http://makandracards.com/makandra/24809-yaml-keys-like-yes-or-no-evaluate-to-true-and-false In order to use the strings ‘yes’ and ‘no’ as keys, you need to wrap them with quotes ...
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
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"}'; ...
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/...
javascript,angularjs,rest,resources
I'm not sure if I follow exactly, but I believe you need to deal with a promise from your POST and then push the result. e.g., dataResources.create($scope.newUserData).$promise.then(function(data) { $scope.usersList.push(data); }); Your service will return a promise and then when the POST is complete your service should return the new user...
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
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...
error code 404 means file not fount. your api link not file name exits. please add full api path for example developer.b24solutions.com/grocery/api/rest/yourfilename Because this link not work in browser. You code is correct but incorrect api link. NSURL *myURL = [NSURL URLWithString:@"http://developer.b24solutions.com/grocery/api/rest/giveyourfilenamewithextension"]; ...
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....
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...
There is no way to access that API publicly any longer. You would need to apply to be part of their partner program to get access to those endpoints once again: https://developer.linkedin.com/partner-programs/apply...
Jersey does not know how to map an instance of SyndFeed to XML. This works. @Path("stackoverflow") public class RomeRessource { @GET @Path("/feed") @Produces("application/rss+xml") public Response getFeed() throws IOException, FeedException { final SyndFeed feed = generate(); // Write the SyndFeed to a Writer. final SyndFeedOutput output = new SyndFeedOutput(); final Writer...
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...
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']; /** *...
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....
ios,objective-c,rest,grand-central-dispatch
GCD does not provide an API to cancel blocks. So you will have to implement this cancellation yourself. The easiest way probably would be to set a global flag 'canceled' and check that inside of your blocks. If the flag is set, immediately return from your block. Then after all...
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...
Influenced by project requirements and the range of preferences amongst members in my team, option 1 will serve us best at this stage. Conforming to the standard HTTP methods will simplify and clarify my API There will be a single, consistent approach to cloning a resource. This outweighs the issue...
Final{"actualPrice":10,"button":"Check Availability","content":"£5 for 6 months, £10 a month for further 6","description":"Fiber broadband","discountedPrice":5} This output represents object but not array, suppose you wait for array. Therefore ng-repeat prints nothing. Should be something like: [ { "actualPrice": 10, "button": "Check Availability", "content": "£5 for 6 months, £10 a month for further...
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...
It is just an expression to add enthusiasm. It isn't to mean that other existing web services architecture aren't build for the web. Since REST is a choice implementation for a lot of lightweight(not much extra xml markup, human readable, no toolkits required to build) requirement, it has gotten...
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...
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
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...
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...
javascript,jquery,rest,sharepoint
You could first map the TypeOfIssueValue values to a new array and then count each occurence based on this answer. The code would be : var a = data.d.results.map(function(issue) { return issue.TypeOfIssueValue }); result = {}; for (i = 0; i < a.length; ++i) { if (!result[a[i]]) result[a[i]] = 0;...
Is that what you're looking for: public enum HttpMethod { POST, DELETE, GET, PUT, HEAD, TRACE, CONNECT, PATCH } class EntityQuery { String field1 String field2 } def createEntity(HttpMethod h, EntityQuery q) { if(!(h in [HttpMethod.POST, HttpMethod.GET])) { throw new Exception('Only POST and GET methods allowed') } } createEntity(HttpMethod.PUT, new...
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...
javascript,jquery,ajax,rest,handlebars.js
You could attempt to try and use JQuery .css() .css("display","block"); // So it would look like this .html(data).css("display","block"); or you could add a setTimeout of 1 or 2 seconds setTimeout(function(){ // Add what you need inside this }, 2000); ...
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...
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 =...
angularjs,rest,typescript,umbraco7
I found another way than @basarat is suggesting, from the comment form @ArghyaC. The problem is that Umbraco's REST controller builds on asp.net's ControllerApi, and defaults to xml. The apostrophes comes from the xml serialize. The solution is simple force json as the return value instead. I don't dare to...
I found out that com.sun.jersey:jersey-core:1.19 doesn't bundle the javax.ws.rs class files and instead lists them as a compile-time dependency. Adding this snippet to my build.gradle fixed the issue. configurations.all { resolutionStrategy { // For a version that doesn't package javax.ws force 'com.sun.jersey:jersey-core:1.19' } } ...
It seems I need to manually specify the key in the URL $result = file_get_contents("https://www.googleapis.com/urlshortener/v1/url?key=" . $apiKey, false, $context); This now works. There must be something funny with how the API inspects POST for the key (or lack of doing so). Edit: For anyone in the future this is my...
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...
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...
I do the same a few days ago... I do this: Convert image to Base64 (byte array => byte[]) Conver byte[] to String Send String with httpPost to server And this is my code to convert image: public String formatPhoto_JPEGtoByteArray (String uri){ // Read bitmap from file Bitmap bitmap =...
php,rest,security,amazon-web-services,token
After you've got token from the client you need to check two things: validity of the token and its timestamp. There are two scenarios: Make timestamp part of the token: function getToken($timestamp) { return $timestamp . encrypt(getPKey(), $timestamp); } $token = genToken(time()); And then validate it: $token = $_POST['token']; function...
Indentation is crucial for yaml files. If your yaml file as same as in the question, the output is totally correct. In order to achieve expected json, first you must fix your yaml file. In order to get your expected json output your yaml file should look like this. Singapoor:...
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...
From the user mailing list, I learned the args to use for generate are: "normalize":boolean "filter":boolean "crawlId":String "curTime":long "batch":String...
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...
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 = "";...
java,javascript,json,angularjs,rest
If AngularJS is accessing your local REST API, the fact that you're running it in a browser on a different port, it counts as a different origin, per the rules of CORS (separate port means separate origin). Two pages have the same origin if the protocol, port (if one is...