1

Can I use Ajax toolkit with a public VF page? I want to insert an object into the DB when a user submit's a form. When I try it it gives me a "Refused to set unsafe header "User-Agent" error with an Invalid Session message.

Can I use Ajax toolkit with a public VF page?

1

The "Unsafe Header" is just a warning and doesn't stop it from working. "Invalid Session" is what the problem is; you need a session ID. You might try:

sforce.connection.sessionId = "{!$Api.Session_ID}";
...
sforce.connection.create([record],{onSuccess: success, onFailure: failure});

Note that the page will run on the Public Site's profile permissions, so if their profile won't allow it, it won't work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.