Skip to content

Instantly share code, notes, and snippets.

@ajaykumarns
Created June 24, 2012 02:39
Show Gist options
  • Save ajaykumarns/2981155 to your computer and use it in GitHub Desktop.
Save ajaykumarns/2981155 to your computer and use it in GitHub Desktop.
Create new product
package com.anadathur.springapp1.example;
import org.springframework.web.client.RestTemplate;
import com.anadathur.springapp1.model.Product;
public class CreateNewProduct{
public static void main(String [] args){
RestTemplate template = new RestTemplate();
Product p = new Product();
p.setName("Apple");
p.setPrice(1.2f);
p.setQuantity(100);
Product product = template.postForObject("http://kick-ass-product/api/product/", p, Product.class);
System.out.println("Created new product: " + product);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment