• deni kurniawan
  • NEWBIE
  • 15 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 4
    Replies
Hi All
I am making a callout to external webservice and when I try running the class I get error like this System.HttpResponse[Status=Not Found, StatusCode=404]

This is link for singpost web service : https://www.ezy2ship.com/modules/oss/api/ship/wsdl?sz_Client=SingPost.json
This is my Apex Class : 
public class testGenerateTicketCon {
    public staff__c test {get;set;}
    public string thisdate {get;set;}
    public string username{get;set;}
    public string password{get;set;}
    public string customerID {get;set;}
    public string output{get;set;}
    public string input {get;set;}
    public string requestlabel;
    public string result{get;set;}
    public String status{get;set;}
    
    public testGenerateTicketCon()
    {
     username='';
     password='';
     customerID=''; 
     thisdate='';
     status='';
    }
    
    public void startRequest(String ticket){ 
        
        HttpRequest req = new HttpRequest();
        Http http = new Http();
        HttpResponse res = new HttpResponse();
        req.setEndpoint('callout:Singapore_Post/getAvailableServicePointsRequest');
        req.setMethod('POST');
        req.setHeader('Content-Type', 'text/xml');
        req.setHeader('Content-Length', '512'); 
        req.setHeader('soapAction', 'https://www.ezy2ship.com/modules/oss/api/ship/index?sz_Client=SingPost.json#getAvailableServicePoints');
  
        res = http.send(req);
        result = res.toString();
       
    }
   
    public void generate()
    {
     thisdate=datetime.now().format('YYYYMMDD');
     input=password;
     string SHA1Coded = EncodingUtil.convertToHex(Crypto.generateDigest('SHA1', Blob.valueOf(input)));
     input=customerid+username+SHA1coded+thisdate;
     blob cryptokey= Crypto.generateAesKey(256);
     Blob data = Blob.valueOf(input);
     Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
     
     output=EncodingUtil.base64encode(encrypteddata);
     output=output.replace('+','-');
     output=output.replace('/','_');
     output=output.replace('=',',');
     
     startRequest(output);
     }
    
}
If anyone can help me?
Hi all
I am trying to building an Application in Android..but I have a issue while I try to load image n display it to listview in native android..is there anyone who can help me?

Thank you


This is for the issue
Hi all
I am newbie programmer android and using salesforce, I was build the application
over all my program work normally..I want change the row layout in listview to be
row layout in listview

any someone can help me..how to setting the row layout and show the image in listview?
Thank you

Good morning all

I have an problem with my coding..I will create new record to object in salesforce..I use restRequest.getRequestForcreate
Nothing an error but while I check the object in salesforce nothing a new record

this is my code

public void createRecords() {

  Map<String, Object> fields = new HashMap<String, Object>();
  fields.put("Table_No__c", picker.getValue());
  try {
   restRequest = RestRequest.getRequestForCreate(
     getString(R.string.api_version), "Order__c", fields);
  } catch (Exception e) {
   // TODO: handle exception
   Toast.makeText(
     MainActivityChoiceTable.this,
     MainActivityChoiceTable.this.getString(SalesforceSDKManager
       .getInstance().getSalesforceR()
       .stringGenericError(), e.toString()),
     Toast.LENGTH_LONG);
  }
}

any someone can help me?
Thank you

Hi everybody
I'm make an Android application, in my apps it can to upload attachment some like picture to salesforce
but I still difficulties about it..so any someone help me tell about the step?

Thank you
Hi all
I am newbie programmer android and using salesforce, I was build the application
over all my program work normally..I want change the row layout in listview to be
row layout in listview

any someone can help me..how to setting the row layout and show the image in listview?
Thank you

Good morning all

I have an problem with my coding..I will create new record to object in salesforce..I use restRequest.getRequestForcreate
Nothing an error but while I check the object in salesforce nothing a new record

this is my code

public void createRecords() {

  Map<String, Object> fields = new HashMap<String, Object>();
  fields.put("Table_No__c", picker.getValue());
  try {
   restRequest = RestRequest.getRequestForCreate(
     getString(R.string.api_version), "Order__c", fields);
  } catch (Exception e) {
   // TODO: handle exception
   Toast.makeText(
     MainActivityChoiceTable.this,
     MainActivityChoiceTable.this.getString(SalesforceSDKManager
       .getInstance().getSalesforceR()
       .stringGenericError(), e.toString()),
     Toast.LENGTH_LONG);
  }
}

any someone can help me?
Thank you

Hi everybody
I'm make an Android application, in my apps it can to upload attachment some like picture to salesforce
but I still difficulties about it..so any someone help me tell about the step?

Thank you

Hi Everyone,

I have an app that uploads and downloads jpeg pictures as attachements to custom salesforce.com objects.

The uploading and storing seems to work fine.

Even the downloading seems to work fine, but for some reason my pictures are coming up black in my Android ImageView.

 

I am converting to and from Base64.

Also my file sizes of these pics are relatively small.  Height 100dp and Width 178dp.  Filesize about 14k.

Below is a sample test activity that I created which has the same issue, but less code to look at.

Any help is greatly appreciated.

 

Thanks!

 

import java.io.UnsupportedEncodingException;
import org.json.JSONArray;
import com.salesforce.androidsdk.app.ForceApp;
import com.salesforce.androidsdk.rest.ClientManager.LoginOptions;
import com.salesforce.androidsdk.rest.RestClient.AsyncRequestCallback;
import com.salesforce.androidsdk.rest.RestClient;
import com.salesforce.androidsdk.rest.RestRequest;
import com.salesforce.androidsdk.rest.RestResponse;
import com.salesforce.androidsdk.ui.NativeMainActivity;
import android.os.Bundle;
import android.app.ProgressDialog;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Base64;
import android.view.Menu;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

public class ImageTest extends NativeMainActivity {
	
	private RestClient client;
	ProgressDialog progressBar;
	int numPics=0;
	String rName="";
	Bitmap bitmap=null;
	Bitmap bitmapTest=null;
	private byte[] buffer=null;
	public static final String IMAGE_STORE = "StorePic";
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_image_test);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.image_test, menu);
		return true;
	}

	@Override
	protected LoginOptions getLoginOptions() {
    	LoginOptions loginOptions = new LoginOptions(
    			null, // login host is chosen by user through the server picker 
    			ForceApp.APP.getPasscodeHash(),
    			getString(R.string.oauth_callback_url),
    			getString(R.string.oauth_client_id),
    			new String[] {"api"});
    	return loginOptions;
	}

	@Override
	protected void onResume(RestClient client) {
        this.client = client; 
		// Show everything
        findViewById(R.id.image_page).setVisibility(View.VISIBLE);		
        try {
			startLoadPicInfo();
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	} //end on resume	
    
    protected void startLoadPicInfo() throws UnsupportedEncodingException {

	    String sfRequest = "SELECT Name, Id, Body, ParentId, BodyLength FROM Attachment "+
	    		"WHERE (ParentId='a1R50000000I95M') AND (Name='StorePic.jpg') ORDER BY CREATEDDATE DESC LIMIT 1";
			try {
				sendPicRequest(sfRequest);
			} catch (UnsupportedEncodingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
    }	
	
	private void sendPicRequest(String soql) throws UnsupportedEncodingException {
		RestRequest restRequest = RestRequest.getRequestForQuery(getString(R.string.api_version), soql);
		client.sendAsync(restRequest, new AsyncRequestCallback() {
			@Override
			public void onSuccess(RestRequest request, RestResponse result) {
				try {
					JSONArray records = result.asJSONObject().getJSONArray("records");
					numPics=records.length();
					if (records.length()>0) {
						for (int i = 0; i < records.length(); i++) {
							buffer = Base64.decode(records.getJSONObject(i).getString("Body").getBytes(), Base64.DEFAULT);
							bitmapTest = BitmapFactory.decodeByteArray(buffer , 0, buffer.length);
							records.getJSONObject(i).getString("Name");
							}   //end for loop - loading results
				 	 }  //end if
					} catch (Exception e) {
						onError(e);
						e.printStackTrace();
					}
					
					if (numPics>0) {		     
			        ImageView sPic = (ImageView)findViewById(R.id.imageView1);
					sPic.setImageBitmap(bitmapTest);
					sPic.bringToFront();
					}
			}
			
			@Override
			public void onError(Exception exception) {
                Toast.makeText(ImageTest.this,
                               ImageTest.this.getString(ForceApp.APP.getSalesforceR().stringGenericError(), exception.toString()),
                               Toast.LENGTH_LONG).show();
			}
		});
	}  //end sendPicRequest()   
}  //end ImageTest

 Here is the activity_image_test.xml

 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:id="@+id/image_page"
    tools:context=".ImageTest" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ab_solid_example" />

</RelativeLayout>