Cannot use Create method with SODataEntity in iOS Native Apps connect to SMP 3.0 SP05

Hi experts,
I am following these blogs:Mobile Application Development Platform for Developers - Native Apps. They are very helpful, thanks Kenichi.
But i have some error when i use Integration gateway.
First, i try method Read, it works perfectly. Then, i try to use method Create, and i meet an error. Here is the error :
Error Domain=NetworkDomain Code=4 "HTTP Response: 403 forbidden" UserInfo=0x7f86d2688040 {NSLocalizedDescription=HTTP Response: 403 forbidden}
I test CRUD method in REST client, and it runs without any errors. I think the difference between Create and Read method is "X-CSRF-Token": Fetch with Read and specific Token with Create. But i do not know how to supply or config "X-CSRF-Token" field when use SOData...
Thanks and Reagrads,
Sao Vu.

Hi Sao,
Is your problem solved?
If not, below code may be able to help you for creation using ODataStore:
MAFLogonRegistrationData *data = [[MyLogonHandler shared].logonManager registrationDataWithError:&error];
    NSString *baseURL = [NSString stringWithFormat:@"%@", data.applicationEndpointURL];
    //opening the store
    self.onlineStore = [[OnlineStore alloc] initWithURL:[NSURL URLWithString:baseURL]
                                httpConversationManager:[MyLogonHandler shared].conversationManager];
    [self.onlineStore openStoreWithCompletion:^(BOOL success) {
//Read request after the store is successfully opened
        SODataRequestParamSingleDefault* readRequest = [[SODataRequestParamSingleDefault alloc] initWithMode:SODataRequestModeRead resourcePath:@"CollectionName"];
        [self.onlineStore scheduleRequest:readRequest delegate:self];
        NSString *finishedSubscription = [NSString stringWithFormat:@"com.sap.sdk.request.delegate.finished.%@",  readRequest];
//Going for create once read request is success
        [[NSNotificationCenter defaultCenter] addObserverForName:finishedSubscription object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
//Creating request for posting the data
SODataRequestParamSingleDefault* insertRequest = [[SODataRequestParamSingleDefault alloc] initWithMode:SODataRequestModeCreate resourcePath:@"CollectionName"];
            insertRequest.payload = entityForCreation; //Assigning the payload
            [self.onlineStore scheduleCreateEntity:entityForCreation collectionPath:@"Collection
Name" delegate:self options:nil];
//Alternatively you can use [self.onlineStore scheduleRequest:insertRequest delegate:self]; also instead of scheduleCreateEntity
If you want to pass X-CSRF-Token with RequestBuilder, you can use the following code:
//Create request for getting the token
      id<Requesting> request = [RequestBuilder requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:endPoint_URL]]];
        /*Set user name */
        [request setUsername:[[NSUserDefaults standardUserDefaults] objectForKey:@"USERNAME"]];
        /*Set password */
        [request setPassword:[[NSUserDefaults standardUserDefaults] objectForKey:@"PASSWORD"]];
        /*Set the required request headers*/
        [request setRequestMethod:@"GET"];
        [odp_Request addRequestHeader:@"X-CSRF-Token" value:@"Fetch"];
        [odp_Request addRequestHeader:@"X-CSRF-Cookie" value:@"Fetch"];
        [request addRequestHeader:@"Content-Type" value:@"application/xml; charset=UTF-8"];
        [request addRequestHeader:@"X-SMP-APPCID" value:applicationConnectionID]];
        [request addRequestHeader:@"X-SUP-APPCID" value:applicationConnectionID]];
        /*Set the delegate to receive the response */
        [request setDelegate:self];
        /*Set the success listener */
        [request setDidFinishSelector:@selector(tokenSuccess:)];
        /*Set the failure listener */
        [request setDidFailSelector:@selector(tokenFailed:)];
        /*Invoke the startAsyncronous API to send the request from client to server asynchronously */
        [request startSynchronous];
//In the tokenSuccess method (- (void)tokenSuccess:(Request*)theRequest), you can use the following code to retrieve the token:
      token=[[theRequest responseHeaders]objectForKey:@"X-CSRF-TOKEN"];
       cookie=[[theRequest responseHeaders]objectForKey:@"SET-COOKIE"];
//Create the request for posting your content to the server
            NSString* requestUrls = [NSString stringWithFormat:@"%@SalesOrders%@", endPoint_URL,filterString];  
            postRequest = [RequestBuilder requestWithURL:[NSURL URLWithString:requestUrls]];
            //             odp_Request = [ODPRequest requestWithURL:[NSURL URLWithString:requestUrls]];
            //id<SDMRequesting> request = [SDMRequestBuilder requestWithURL:[NSURL URLWithString: requestUrls]];
            [postRequest setUsername:[[NSUserDefaults standardUserDefaults] objectForKey:@"USERNAME"]];
            [postRequest setPassword:[[NSUserDefaults standardUserDefaults] objectForKey:@"PASSWORD"]];
            [postRequest setDelegate:self];
            [postRequest setRequestMethod:@"POST"];
            [postRequest addRequestHeader:@"content-type" value:@"application/atom+xml;type=entry"];
            [postRequest addRequestHeader:@"X-SMP-APPCID" value:applicationConnectionID]]; //Assinging the applicationConnectionID value to the request
            [postRequest addRequestHeader:@"X-CSRF-Token" value:token]; //Assinging the token value to the request
            [postRequest addRequestHeader:@"Cookie" value:cookie]; //Assinging the cookie value to the request
            [postRequest appendPostData:[xml dataUsingEncoding:NSUTF8StringEncoding]]; //Appending the body of the request
            [postRequest setDidFailSelector:@selector(updaterequestFailed:)]; //Failure delegate method
            [postRequest setDidFinishSelector:@selector(updaterequestFinished:)];  //Success delegate method
            [postRequest setTimeOutSeconds:200]; //Timeout for request
            [postRequest startSynchronous];
Hope this will help you.
Regards,
Dhani

Similar Messages

  • Plugin for Acrobat Reader cannot use DigSig methods?

    Hi,
    I have an acrobat plugin created using acrobat sdk 9, registered using PubSec. Now, i want to make it run for adobe reader aswell. but i read the following somewhere:
    You may not use the Adobe Reader key to develop or enable your plug-in or any other software or hardware to perform or enable any of the following:
    Add functionality to Adobe Reader that is substantially similar to functionality in commercially available Acrobat products
    Accept navigational commands from an application other than Adobe Reader
    Create, remove, or modify any Enabling Rights (including but not limited to permissions added to a PDF file with a product such as Adobe LiveCycle™ Reader Extensions (formerly Adobe Reader Extensions Server)
    Save or modify any Acrobat file (including without limitation PDF, FDF, or annotation)
    Extract and save any content from a PDF file (other than submitting form data to a remote server)
    Use any APIs from the Forms or DigSig Host Function Tables (HFTs)
    Modify the appearance of Adobe Reader
    Remove the menu item that calls up the "About" screen in Adobe Reader
    Implement a Replacement File System (RFS) for Adobe Reader"
    Does this mean that i cannot use a plugin registered using DigSig HFT   OR    that i cannot use DigSig methods in my plugin, which i have used generously?
    If the latter, then does this mean i'll have to remove all DigSig method usage from my plugin?
    Thanks

    It means you need a special Reader-enabling license.  When you send in your Reader IKLA (integrated key license agreement) you need to specify that you are doing something related to DigSig so that they can send you the revised agreement and pricing model.

  • How to create an instance for RemoteSession without using create() method

    How to create an instance for RemoteSession without using create() method?

    What's RemoteSession? Not in the JDK. And does the question have anything to do with concurrency?

  • Why not to use static methods - with example

    Hi Everyone,
    I'd like to continue the below thread about "why not to use static methods"
    Why not to use static methods
    with a concrete example.
    In my small application I need to be able to send keystrokes. (java.awt.Robot class is used for this)
    I created the following class for these "operations" with static methods:
    public class KeyboardInput {
         private static Robot r;
         static {
              try {
                   r = new Robot();
              } catch (AWTException e) {
                   throw new RuntimeException(e + "Robot couldn't be initialized.");
         public static void wait(int millis){
              r.delay(millis);
         public static void copy() {
              r.keyPress(KeyEvent.VK_CONTROL);
              r.keyPress(KeyEvent.VK_C);
              r.keyRelease(KeyEvent.VK_C);
              r.keyRelease(KeyEvent.VK_CONTROL);
         public static void altTab() {
              r.keyPress(KeyEvent.VK_ALT);
              r.keyPress(KeyEvent.VK_TAB);
              r.keyRelease(KeyEvent.VK_TAB);
              r.keyRelease(KeyEvent.VK_ALT);
                   // more methods like  paste(), tab(), shiftTab(), rightArrow()
    }Do you thinks it is a good solution? How could it be improved? I've seen something about Singleton vs. static methods somewhere. Would it be better to use Singleton?
    Thanks for any comments in advance,
    lemonboston

    maheshguruswamy wrote:
    lemonboston wrote:
    maheshguruswamy wrote:
    I think a singleton might be a better approach for you. Just kill the public constructor and provide a getInstance method to provide lazy initialization.Thanks maheshguruswamy for advising on the steps to create a singleton from this class.
    Could you maybe advise also about why do you say that it would be better to use singleton? What's behind it? Thanks!In short, it seems to me that a single instance of your class will be able to coordinate actions across your entire application. So a singleton should be enough.But that doesn't answer why he should prefer a singleton instead over a bunch of static methods. Functionally the two are almost identical. In both cases there's only one "thing" on which to call methods--either a single instance of the class, or the class itself.
    To answer the question, the main reason to use a Singleton over a classful of static methods is the same reason the drives a lot of non-static vs. static decisions: Polymorphism.
    If you use a Singleton (and and interface), you can do something like this:
    KeyboardInput kbi = get_some_instance_of_some_class_that_implements_KeyboardInput_somehow_maybe_from_a_factory();And then whatever is calling KBI's public methods only has to know that it has an implementor of that interface, without caring which concrete class it is, and you can substitute whatever implementation is appropriate in a given context. If you don't need to do that, then the static method approach is probably sufficient.
    There are other reasons that may suggest a Singleton--serialization, persistence, use as a JavaBean pop to mind--but they're less common and less compelling in my experience.
    And finally, if this thing maintains any state between method calls, although you can handle that with static member variables, it's more in keeping with the OO paradigm to make them non-static fields of an instance of that class.

  • HT204291 Help! I cannot see the Airplay symbol on any of my devices anymore!  I have tried following all guides and troubleshooting, but to no avail. Just cannot use the AppleTV with any of my devices.

    Help! I cannot see the Airplay symbol on any of my devices anymore!  I have tried following all guides and troubleshooting, but to no avail. Just cannot use the AppleTV with any of my devices.

    Thanks for the link. It didn't work at first on any of the devices but then I decided to enter a manual DNS instead of an automatic configuration. Then followed the steps again from your link and it worked.
    It is not stable though as I need to reset the device for it to see the airplay. But when it is connected it stays connected for 30 minutes approx.
    Any other suggestions to keep it stable would be fantastic but at least in the meantime I have a workaround.
    Thanks

  • Cannot use face time after upgrating to ios 6 .password is not recognisible.pls help urgently

    I cannot use face time after updating to IOS 6'password  is not recognisible here nor to imessage pls help urgently

    Using FaceTime http://support.apple.com/kb/ht4319
    Troubleshooting FaceTime http://support.apple.com/kb/TS3367
    The Complete Guide to FaceTime: Set-up, Use, and Troubleshooting Problems
    http://tinyurl.com/32drz3d
     Cheers, Tom

  • I cannot use downloaded ringtons with my Contacts.Ringtones downloaded by programme  Ringtones

      I cannot use downloaded  ringtons with my Contacts.Ringtones downloaded by programme  Ringtones

    Reinstalling OS X Without Erasing the Drive
    Boot to the Recovery HD: Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
    Repair the Hard Drive and Permissions: Upon startup select Disk Utility from the main menu. Repair the Hard Drive and Permissions as follows.
    When the recovery menu appears select Disk Utility. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the main menu.
    Reinstall OS X: Select Reinstall OS X and click on the Continue button.
    Note: You will need an active Internet connection. I suggest using Ethernet if possible because it is three times faster than wireless.
    Also see:
    Reinstall OS X Without Erasing the Drive
    OS X Lion- Reinstall Mac OS X
         Note: You will need an active Internet connection. I suggest using Ethernet
                     if possible because it is three times faster than wireless.

  • "You cannot use this application with this version of OS X"

    Hi,
    I'm getting this message when I try to open .AVI files that I uploaded from my digital camera, but I'm posting it here instead of in the Quicktime section because I believe that the cause of the problem is more general. When researching this problem, I looked at the info panel for these .AVI files, and the app listed to open them was "Quicktime Player (default) (7.1.3)". But the actual version of Quicktime that I have installed is version 7.4. If I set the file's "Open With" app to be "Quicktime 7.4", it opens fine, but the "Open With" app reverts back to "Quicktime Player (default) (7.1.3)", making the problem come back. I've also noticed that if I right-click on other apps (a PDF file, for example), and choose "Open With" from the popup menu, that I see other versions of apps that no longer exist on my machine (Safari 2.0.4, for example). I think that files associated with these older app versions may be the cause of many of the "You cannot use this application with this version of OS X" issues that have been reported here. My question is where is this list of "installed" products maintained in OS X, and is there a way that I can edit it to remove those product versions that no longer exist on my system. In my particular instance, I'd like to remove "Quicktime 7.1.3" which should allow me to set the associated app for my .AVI files to be Quicktime 7.4 with no possibility of the association reverting to an earlier version that's not only incompatible with Leopard, but also not installed on my system.
    Thanks,
    Ken

    When you associate a file with an application, are you then clicking the "Change All" button? You can rebuild the LaunchServices database. Evidently the location of the command and the database have changed slightly in Leopard from what they were in Tiger. See this thread for the updated instructions:
    http://discussions.apple.com/thread.jspa?messageID=5730491
    Also, make sure you don't have the old applications archived somewhere. I've been astonished in the past at just how enterprising the system can be in finding some program squirreled away in an obscure backup folder and listing it as an option to open something.
    Francine
    Francine
    Schwieder

  • Cannot use push notification with Whatsapp

    Cannot use push notification with Whatsapp and pop up "Connect iTune for Push Notification" when open Whatsapp

    http://www.whatsapp.com/faq/en/iphone/20950116
     Jackson

  • I have iPhone 6,  8.3. I cannot use bluetooth at all from my device, even to connect my macbook pro. I did all the recommended trouble shooting such as  reboot and reset network settings. but it does not recognise any bluetooth device. Pls help.Thank

    I have iPhone 6,  8.3. I cannot use bluetooth at all from my device, even to connect my macbook pro. I did all the recommended trouble shooting such as  reboot and reset network settings. but it does not recognise any bluetooth device. Pls help.Thank you.

    See iPhone BT profile on what can be connected/paired:
    iOS: Supported Bluetooth profiles - Apple Support
    And BT troubleshooting:
    iOS: Troubleshooting Bluetooth connections - Apple Support

  • Hi, I have a macbook pro 17" 2.4ghz intel core 2 duo 2007, will upgrading to Yosemite slow me down or create problems with my Iphone or other app ?

    Hi, I have a macbook pro 17" 2.4ghz intel core 2 duo 2007, will upgrading to Yosemite slow me down or create problems with my Iphone or other app ?

    Yes, i do not suggest upgrading right now. There is some software malfunction or glitch that spontaneously shuts down this specific model. I upgraded and it was a pain to downgrade and make my mac usable again.

  • HT5484 Hi, I am using "Avenir Heavy" font in my iOS 6 app but when I run it on iOS5 the label on which I am placing Avenir fonts changes lot and I am not getting proper look n feel. How can I solve this issue ?

    Hi, I am using "Avenir Heavy" font in my iOS 6 app but when I run it on iOS5 the label on which I am placing Avenir fonts changes lot and I am not getting proper look n feel. How can I solve this issue ?

    Post your question on the Developer forums:  http://devforums.apple..com

  • Problem with getDefinition method in ApplicationDomain for iOS AIR app

    I was using getDefinition method in ApplicationDomain to get class definition of an exported symbol from an external swf. It used to work fine with debug builds even on iOS. But when i exported a release build and installed the ipa file on iPad it stopped working. I debugged and found out that getDefinition is returning null in case of release builds on iPad.
    Is it a known issue? If yes, is there any workaround present ?

    Fast packaging in Flash Builder internally uses interpreter mode.
    The "Export Release Build" option generates an AOT build which uses ipa-app-store. For more on different target types in AIR iOS, refer:
    http://help.adobe.com/en_US/air/build/WS901d38e593cd1bac1e63e3d128cdca935b-8000.html
    When you export some symbol (in say Flash Pro via AS Linkage), actionscript byte code is inserted in your SWF. As this SWF hasn't been AOTed, you are not able to access the symbols in it in a release build. Presently there is no way to AOT external swfs. Using the currently available tools, your best bet is to create a single SWF and then "export release build"

  • HT6154 I tried to update software for my iphone...now I cannot use it-stuck with an itunes logo and the plu..when I go to itunes to look for my name iwth device there is nothing

    I tried to update my iphone,,ran downstairs ot garden since it took 30 minutes.  I cam e back with an itunes logo and plug on the front cannot use my phone or call it....apple's store in tampa is close...I will probably get in a car accident on my way to the store 1 hour and 30 minutes away after I get pulled over for speeding after I get a flat tire(;

    Hello hstacy
    Check out the articles below to troubleshoot issues with resolving issue with issues updating your iPhone. If you are having issues with it not being seen, pick one of the two articles that goes with the type of computer you have.
    If you can't update or restore your iOS device
    http://support.apple.com/kb/HT1808
    iOS: Device not recognized in iTunes for Windows
    http://support.apple.com/kb/ts1538
    iOS: Device not recognized in iTunes for Mac OS X
    http://support.apple.com/kb/ts1591
    Regards,
    -Norm G.

  • Using onFocus method with embedded html

    Hi,
    I have embedded html in a servlet. I am using a text field to call the onFocus method with the following code:
    out.println("<input type='text' name='name' value='0' onFocus='if(this.value=='0')this.value=';'>");
    If I was using straight html with no servlet this works fine. When the user clicks on the field the default value is automatically erased.
    Why will this not work in a servlet?
    I have also tried calling a javascript function. Please note that I successfully use javascript with input type 'button' to render a pop up window with dimensions. So my javascript inside a servlet works elsewhere.
    Thanks VERY MUCH for your time
    Rick

    I don't think it's the same as I'm doing. Essentially, I have a JEditorPane subclass, which just has a few custom tags in it. I don't need them to be recognized by java, since it will be uneditable, but I just need to know how to convert from the getText() locations to the actual displayed text locations.
    Also, when I set the text as text/html, it creates a bunch of extra HTML tags, so it's larger than the original String used to create it.

Maybe you are looking for

  • Black screen after updating to ios 8 iphone 4s

    iPhone 4S Cap 56,5 GB IOS 8.0.2 Model MD261HN/A Modem Firmware 5.4.00 Guys, since upgrade to IOS 8.0.0 I am getting black screens or crash in most apps (Facebook, Whatsapp, etc). That has never happened before and I own this phone for about 3 years.

  • Restore to Factory settings for A-210 with obstacles

    Hello, I have read a number of posts on this question, but the solutions there don't seem to work. 1. I didn't get restore cd's at purchase 2. I might have made restore cd's but I don't know where they could be ... 3. the optical drive is broke 4. At

  • Regarding the event AT SELECTION-SCREEN ON FIELD ..

    Hi experts, Can u plz tell the real advantage of the event AT SELECTION-SCREEN ON FIELD than AT SELECTION-SCREEN .. in which type of situations  AT SELECTION-SCREEN ON FIELD is needed?? Thanks & Regards, sathish.

  • Contact Center. Campaign outbounds??

    Hi, I'm new to these issues and am trying to make a campaign outbounds for a contact center. In  the documentation indicates that the contact information is entered in  plain text are the separator comma, but it is producing an error  importing conta

  • How does this program work on  a Mac OS-X 10.8.5?

    How does Adobe Photoshop Elements and Adobe Premiere work on a MAC OS-X 10.8.5?  Do I need additional software?