If I generate a before or after create handler, and don’t add any other code, all create requests return an error 400 Bad Request.
Do you run the handler in the debug mode or in production?
Is it a “catch-all” handler or for a specific table?
Everything works in local debug mode, but I only get errors when I deploy anything. I generated a brand new empty handler and its also returning error 400. Its for a specific table.
Is it possible for you to share your table’s generated class?
this?
@Asset( "Comment" )
public class CommentTableEventHandler extends com.backendless.servercode.extension.PersistenceExtender<Comment>
{
@Override
public void afterCreate( RunnerContext context, Comment comment, ExecutionResult<Comment> result ) throws Exception
{
// add your code here
}
@Override
public void beforeCreate( RunnerContext context, Comment comment) throws Exception
{
// add your code here
}
}
Oh, no, I mean your Comment.java class, it should be in “models” package.
public class Comment
{
private String objectId;
private java.util.Date updated;
private BackendlessUser author;
private java.util.Date created;
private String text;
private String parentId;
private String authorName;
private String ownerId;
private String videoId;
private String authorUsername;
public String getObjectId()
{
return this.objectId;
}
public java.util.Date getUpdated()
{
return this.updated;
}
public BackendlessUser getAuthor()
{
return this.author;
}
public java.util.Date getCreated()
{
return this.created;
}
public String getText()
{
return this.text;
}
public String getParentId()
{
return this.parentId;
}
public String getAuthorName()
{
return this.authorName;
}
public String getOwnerId()
{
return this.ownerId;
}
public String getVideoId()
{
return this.videoId;
}
public String getAuthorUsername()
{
return this.authorUsername;
}
public void setObjectId( String objectId )
{
this.objectId = objectId;
}
public void setUpdated( java.util.Date updated )
{
this.updated = updated;
}
public void setAuthor( BackendlessUser author )
{
this.author = author;
}
public void setCreated( java.util.Date created )
{
this.created = created;
}
public void setText( String text )
{
this.text = text;
}
public void setParentId( String parentId )
{
this.parentId = parentId;
}
public void setAuthorName( String authorName )
{
this.authorName = authorName;
}
public void setOwnerId( String ownerId )
{
this.ownerId = ownerId;
}
public void setVideoId( String videoId )
{
this.videoId = videoId;
}
public void setAuthorUsername( String authorUsername )
{
this.authorUsername = authorUsername;
}
public Comment save()
{
return Backendless.Data.of( Comment.class ).save( this );
}
public Long remove()
{
return Backendless.Data.of( Comment.class ).remove( this );
}
public static Comment findById( String id )
{
return Backendless.Data.of( Comment.class ).findById( id );
}
public static Comment findFirst()
{
return Backendless.Data.of( Comment.class ).findFirst();
}
public static Comment findLast()
{
return Backendless.Data.of( Comment.class ).findLast();
}
}
I just deployed a no-op “create” event handler and tried a few REST requests to add data objects. It worked as expected. Could you try adding an object using the REST Console? It is available on the Data screen (there is a separate tab there). You will need to enter a JSON object into the Request field and click the POST button.
This is what I get, it doesn’t show headers or status code, but its the same response Im getting with 400:
{
“message”: null,
“code”: 0
}
Could you please let me know your app id?