Lulu Developer Forums

API Applications

RSS Feed

Create operation

    • bg77
    • Topic created 2 years ago

    Hi, this is my first project using lulu api in c#.net and I am having little bit trouble. I successfully got auth_token, upload_token and I uploaded my pdf file. but when I try to create the project, it gives me error 403 which indicates that i dont have permission. I tried everything I know but nothing so far. if you guys can help me with this or give me some clues, I appreciate.

    Thanks.

    Message edited by bg77 2 years ago

  1. Josiah Gore2 years ago

    Could you give us some more clues as to what you are encountering? What do the response body and response headers look like? Are you passing the auth_token as a query string parameter with each call?

  2. bg772 years ago

    postdata = "api_key=" + apiKey; postdata += "&auth_user=(auth_user value that I used to get a auth_token)"; postdata += "&auth_token =" + authToken; postdata += "&project=" + j_son; byte[] data1 = encoding.GetBytes(postdata); myRequest = (HttpWebRequest)WebRequest.Create("https://apps.lulu.com/api/publish/v1/create"); myRequest.Method = "POST"; myRequest.ContentType = "application/x-www-form-urlencoded"; myRequest.ContentLength = data1.Length; newStream = myRequest.GetRequestStream(); newStream.Write(data1, 0, data1.Length); webResponse = myRequest.GetResponse(); (it gives error 403 here) stream = webResponse.GetResponseStream(); reader = new StreamReader(stream); string content_id = reader.ReadToEnd();

    My code looks like this and I am using webrequest for the first time but it worked for previous operations but not for this. do I need another permission for Create operation?

  3. Josiah Gore2 years ago

    The authentication requirements for the create call are the same as for the other calls. As long as you're supplying a correct api_key and auth_token it should work. You will likely need to be URL encoding the auth_token. Is that encoding.GetBytes(postdata) call URL encoding the POST data?

    Are you able to get ahold of the raw response headers and body using the web request library?

    1. for (int i=0; i < webResponse.Headers.Count; ++i)
    2.     Console.WriteLine("\nHeader Name:{0}, Value :{1}",webResponse.Headers.Keys[i], webResponse.Headers[i]);
    3. StreamReader responseReader = new StreamReader(webResponse.GetResponseStream());
    4. Console.WriteLine(responseReader.ReadToEnd());
  4. bg772 years ago

    byte[] data1 = encoding.GetBytes(postdata); newStream.Write(data1, 0, data1.Length);

    The api_key I am using is defined as a global variable and I am taking it from that variable always. So, since other operations are performing smoothly, there shouldn't be a problem related to it. Yes it does. I created a string and added all necessary variables to perform create operation, then I encoded them to a byte array and posted it.

    I didn't understand what is your code is doing as I am a newbie but if it is not too much to ask, can you give me an example how you would perform create operation? Coz obviously mine is not working and honestly I am out of solutions.

    Thanks

[ Page 1 of 1 ]