Create Advertisement Using API

Forums Support Create Advertisement Using API
Jaspreet Singh Lamba less than a year ago - 2016-08-03 12:29:24
Hi, I am trying to create a New Advertisement using API, but every time I get the same error. 

- Object {code: 500, error: "Category must not be empty - Title must not be empty - Description must not be empty - "}

Can you tell me what is the issue. 

This is my Data Object that I have created : Object {id_user: 1, id_category: 2, title: "Testing Advertisement Edit Feature", description: "Hello World"}
Jaspreet Singh Lamba less than a year ago - 2016-08-03 12:30:28
This is the URL that i generate for creating a new Advertisement :http://webtechevolution.yclas.com/api/v1/ads
Constantinos less than a year ago - 2016-08-03 13:46:45
Hello,

You need to make sure that the category with id=2 exists.

Here: http://webtechevolution.yclas.com/api/v1/categories

I can see that you have only one category with id=1.

It seems that was wrong, you need to change it when you try to create a new ad!

Regards
Jaspreet Singh Lamba less than a year ago - 2016-08-03 14:16:55
Hi,
Just getting the same error again. I tested it with category 1 as well.
Object {id_user: 1, id_category: 1, title: "Testing Advertisement Edit Feature", description: "Hello World"}

I have even passed my user_token into as well. But still getting the same error : 
POST URL  : http://webtechevolution.yclas.com/api/v1/ads?user_token=590a3341.........
Constantinos less than a year ago - 2016-08-03 14:22:44
Can you please paste here the whole post URL, without the user_token?
Jaspreet Singh Lamba less than a year ago - 2016-08-03 14:25:46
This is the data : 
createAdvertisementUrl :  "http://webtechevolution.yclas.com/api/v1/ads?user_token=590a334....";
    var data = ({
      id_user : 1,
      id_category: 1,
      title: "Testing Advertisement Edit Feature",
      description : "Hello World"
    });

    var config = {
      headers : {
          'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
      }
    }

POST REQUEST : 
$http.post(createAdvertisementUrl, data, config)
      .success(function (data, status, headers, config) {
          console.log("SUCCESS");
          
      })
      .error(function (data, status, header, config) {
          console.log("ERROR");
          
      });
  }
Constantinos less than a year ago - 2016-08-03 15:22:47
Please check first that it works by running the URL in your browser. If it does, then you need to review your code.

Regards
Jaspreet Singh Lamba less than a year ago - 2016-08-04 09:04:33
Hi,

I solved the issue. The issue was with Angular JS HTTP Request Method. Instead I used jQuery for that and it worked like a charm.

Now I am facing problem in adding an image with my Advertisement. i have created an Advertisement and not able to add image to it. Here is the URL for the same : http://webtechevolution.yclas.com/api/v1/ads/image/15?user_token=590a3341......
where,
15 - ID_AD
and my image is in base 64 encoded format : 
var data = {
      "image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA8UAAAO9CAIAAAAkIVKXAAAAi....."
    };

Can you please suggest me the issue in it. 
Always I get the following error : {"code":404,"error":"Advertisement not found"}, though Advertisement 15 is already created.
URL to access all Advertisements : http://webtechevolution.yclas.com/api/v1/ads?user_token=590a334166389c2f61765c00c0b46ed76bc3381b
Constantinos less than a year ago - 2016-08-04 15:31:56
Hello,

The issue is in your code when it sends the image. Please review the code ;)

Regards
Jaspreet Singh Lamba less than a year ago - 2016-08-05 05:54:53
Hi,

I am even not able to understand the error, can you please look into it.
Chema less than a year ago - 2016-08-05 07:26:16
If you read our API the image needs to be sent via POST.

regards
Jaspreet Singh Lamba less than a year ago - 2016-08-05 08:02:08
I am using Post method.
Heres my Request Method : 
attachAdvertisementImageUrl = BASE_URL + "v1/ads/image/15?user_token=590a33416638";
var data = {
"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA8UAAAO...."
};
$.ajax({
      url: attachAdvertisementImageUrl, 
      data:data,
      type: "POST",
      error: function (request, error) {
        console.log("error");
        console.log(error);
      },
      success: function (response) {
        console.log("Success");
        console.log(response);
      }
    });
Jaspreet Singh Lamba a couple of months ago - 2016-08-19 08:16:02
Hi,

Can you please look into this. Its almost a week I have been trying adding an image.
It would be good if you can provide me with a dummy web service URL for the same.
Constantinos a couple of months ago - 2016-08-19 10:54:44
Hello,

We cannot provide code for the API. If you need help with that, you can purchase the native apps:
https://yclas.com/android-app.html
https://yclas.com/ios-app.html

Regards
Topic Closed