Timeline item update error - google-glass

I have a bundle of timelineitems using Mirror API, Now I am trying to change content of a timeline from bundle. But the below error occurs
An error occurred from update timeline : com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
{
"code" : 404,
"errors" : [ {
"domain" : "global",
"message" : "Not Found",
"reason" : "notFound"
} ],
"message" : "Not Found"
}
And update method is something like below
public static TimelineItem updateTimelineItem(Credential credential,
String itemId, String newText) {
try {
Mirror.Timeline timeline = getMirror(credential).timeline();
TimelineItem timelineItem = timeline.get(itemId).execute();
timelineItem.setText(newText);
return timeline.update(itemId, timelineItem).execute();
} catch (IOException e) {
System.err.println("\nAn error occurred from update timeline : " + e);
return null;
}
}
First I try to retrieve the timeline item, when I write execute, then the error occurred
Mirror.Timeline timeline = getMirror(credential).timeline();
TimelineItem timelineItem = timeline.get(itemId).execute();
How can I solve it?

It isn't completely clear from the exception you've posted, but it looks like the itemId isn't valid. How are you getting this itemId and can you verify if it is the timeline.get or the timeline.update that is causing the problem?

Related

com.apollographql.apollo.exception.ApolloHttpException: HTTP 500 Internal Server Error

I keep getting the HTTP 500 Internal Server Error in my android studio trying to call a loginQuery with apollo client for android, following this tutorial : link to apollo docs
Yet when I run the same query in graphiQL in my browser, it succeeds.
here's a picture of the error in studio :
here's my code:
String userNumber = numberInput.getText().toString();
String password = passwordInput.getText().toString();
Intent intent;
LogInQuery logInQuery = LogInQuery.builder().nationalID(userNumber).password(password).build();
apolloClient.query(logInQuery).enqueue(new ApolloCall.Callback<LogInQuery.Data>() {
#Override
public void onResponse(#NotNull Response<LogInQuery.Data> response) {
LogInQuery.Data data = response.getData();
List<Error> error = response.getErrors();
assert error != null;
String errorMessage = error.get(0).getMessage();
assert data != null;
Log.d(TAG, "onResponse: " + data.login() + "-" + data.login());
if(data.login() == null){
Log.e("Apollo", "an Error occurred : " + errorMessage);
runOnUiThread(() -> {
// Stuff that updates the UI
loading.setVisibility(View.GONE);
Toast.makeText(LogInActivity.this,
errorMessage, Toast.LENGTH_LONG).show();
});
} else {
runOnUiThread(() -> {
// Stuff that updates the UI
loading.setVisibility(View.GONE);
Toast.makeText(LogInActivity.this,
"New User Created!", Toast.LENGTH_LONG).show();
//Intent intent = new Intent(LogInActivity.this, LogInActivity.class);
//startActivity(intent);
});
}
}
#Override
public void onFailure(#NotNull ApolloException e) {
runOnUiThread(() -> {
Log.e("Apollo", "Error", e);
Toast.makeText(LogInActivity.this,
"An error occurred : " + e.getMessage(), Toast.LENGTH_LONG).show();
loading.setVisibility(View.GONE);
});
}
});
}
I can't find much on the internet to help me solve it. If it's duplicate, direct me to the correct answer.
Check your API in Postman. It's working fine or not! Please share API if possible.

How to fix On error Facebook log in result in android

when I click on the button of sign in the window of choosing facebook profile appears ! but once I confirm the the profile the app crashes . And by using logs I figured out that the register call is not successful so I'have a facebook exeception which causes error , how can i find the source error ?
facebookSignInButton.setOnClickListener(View.OnClickListener {
// Login
Log.i(TAG,"CLICKED")
loginManager.logInWithReadPermissions(this, Arrays.asList("public_profile"))
Log.i(TAG,"Permissions")
loginManager.registerCallback(callbackManager,
object : FacebookCallback<LoginResult> {
override fun onSuccess(loginResult: LoginResult) {
Log.d(TAG, "Facebook token: " + loginResult.accessToken.token)
startActivity(Intent(applicationContext,MainActivity::class.java))
}
override fun onCancel() {
Log.i(TAG, "Facebook onCancel.")
}
override fun onError(error: FacebookException) {
Log.d(TAG, "Facebook onError.")
// This part is written in run console
}
})
})
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
callbackManager!!.onActivityResult(requestCode, resultCode, data)
Log.i(TAG,"RESULT"+resultCode.toString()) // this retrun -1
Log.i(TAG,"REQUEST"+requestCode.toString())
}
I expect starting a new activity while logging.
After printing the msg error the problem is in the hash key it doesn't match any key stored !
so instead if using line cmnds I just use this code in my on create function and then copy the hash key into your facebook developer app
val packageName = this.getApplicationContext().getPackageName()
val info : PackageInfo = getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
for ( signature in info.signatures) {
var md = MessageDigest.getInstance("SHA")
md.update(signature.toByteArray())
val hashKey = android.util.Base64.encodeToString(md.digest(), 0)
Log.i(TAG,"HADHKEEEY"+hashKey)
}
Log.i(TAG,"NAAAMEE"+packageName)

WSO2 DataService (DataSource) Return Custom Error Message

How to return Custom Error Response when using WSO2 EI(6.5.0) DataService
I am getting this error when validation input values :
{
"Fault": {
"faultcode": "axis2ns16:VALIDATION_ERROR",
"faultstring": "DS Code: VALIDATION_ERROR\nNested Exception:-\njavax.xml.stream.XMLStreamException: DS Code: VALIDATION_ERROR\nSource Data Service:-\nName: MWGetBranchCodes\nLocation: \\MWGetBranchCodes.dbs\nDescription: N/A\nDefault Namespace: http://ws.wso2.org/dataservice\nCurrent Request Name: _post_getbankcodes\nCurrent Params: {SOURCE=source, REQUESTER=bond, FUNCTION=function, SECURITYCODE=1FE550839D5DD7933032340DA85F614}\nNested Exception:-\nSecuritycode and Function are not matched : \nField Name: SECURITYCODE\nField Value: 1FE550839D5DD7933032340DA85F614\n\n",
"detail": ""
}
}
i want this :
{
"Error": {
"ErrorCode": "0", 0-failed/ 1-success
"ErrorMessage": "VALIDATION_ERROR : Securitycode is NULL",
"detail": " \nField Name: SECURITYCODE\nField Value: null\n\n"
}
}
Help me please Thanks.
I think that for that behaviour you need to create custom validators, check this post:
http://mycodeideas.blogspot.com/2016/07/custom-validators-with-wso2-dss.html

without Error in my code i am getting error in postaman #PostMapping

I write code for Restful services.in postman when i tried to send a request by using #Postmapping its getting error in postaman
this is my controller class
public class BookController {
private BookRepository bookrepository;
#PostMapping("/addBook")
public String save(#RequestBody Book book)
{
bookrepository.save(book);
return "added book with id"+book.getId();
}
#GetMapping("/findAllBooks")
public List<Book> getBooks()
{
return bookrepository.findAll();
}
#DeleteMapping("/delete")
public String deleteBook(#PathVariable int id){
bookrepository.deleteById(id);
return "book deleted"+id;
}
}
when i send a request to postman by post method at the time i m getting a error like the below
{
"timestamp": "2019-03-27T12:22:20.319+0000",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/addBook"
}

Facebook Graph API: The remote server returned an error: (400) Bad Request instead of error inside

I have a code that make a Get request to Facebook Graph API to get business account.
This is code:
var facebookBusinessAccountId = ConfigurationManager.AppSettings["facebook_business_account_id"];
facebookRestUrl += "&access_token=" + acct.AccessToken;
facebookRestUrl = facebookRestUrl.Replace("{0}", facebookBusinessAccountId);
var request = WebRequest.Create(facebookRestUrl);
request.Method = "GET";
request.ContentType = "application/json";
var response = request.GetResponse(); (Error here)
The URI look like:
https://graph.facebook.com/v3.1/1x8xx4005xxxxxx?fields=business_discovery.username(yess_cub){biography,id,ig_id,profile_picture_url,username,website}&access_token=EAAJ..
It should be return error like this:
{
"error": {
"message": "Invalid user id",
"type": "OAuthException",
"code": 110,
"error_subcode": 2207013,
"is_transient": false,
"error_user_title": "Cannot find User",
"error_user_msg": "The user with username: yess_cub cannot be found.",
"fbtrace_id": "BMEAcyYOZf9"
}
}
But error : The remote server returned an error: (400) Bad Request is what I get
Could anyone please help me?
Thanks alot!
I found an idea and catch the inner exception from try/catch statement
It should be like this:
catch (WebException ex)
{
using (StreamReader reader = new StreamReader(ex.Response.GetResponseStream()))
{
string jsonMessageString = reader.ReadToEnd();
}
}