The Hibs ace, 29, allegedly told PC Katherine Eager that his name was Johnstone, moments after her colleague, PC Andrew Morrow, is said to have seen him taking the class A drug.
Edinburgh Sheriff Court heard that when O’Connor was asked to spell Johnstone, he replied: “J-O-S”, before pushing her and running away for 300 metres.
The revelation came on the first day of a trial in which O’Connor, of Dirleton, East Lothian, stands accused of cocaine possession and resisting police arrest on 14 May, 2011.
The court heard that police did not caution O’Connor when they spoke to him after allegedly seeing him taking drugs.
Defence solicitor advocate Liam O’Donnell believes his client was therefore arrested illegally and should be acquitted of the charge.
Mr O’Donnell told the court: “They [the police officers] should know the law they are purporting to be exercising. They don’t. They should be doing their job properly.”
The court heard how PC Eager, 27, and PC Morrow, 34, were patrolling Edinburgh city centre in the early hours of 14 May last year when they spotted a large white Land Rover parked in Hope Street Lane.
PC Morrow said there were four people in the vehicle.
He told the court that he saw a man in the back of the vehicle snorting what he thought were drugs.
He told depute procurator-fiscal Ian Wallace that he recognised the man who he suspected of taking the drugs as the person who was sitting in the dock of the court: O’Connor.
PC Morrow then said that he and his colleague went to speak to the people inside the Land Rover.
PC Eager told the court that she went to speak to O’Connor while her colleague spoke to another person sitting in the car.
She told the court that she could see “white powder” and a rolled up £20 note beside O’Connor.
“He was quite shifty,” she said. “He was moving about a lot. He couldn’t sit still. I asked him his name. He said it was Johnstone. I asked him how to spell it. He replied: ‘J-O-S’.
“At that point he pushed past me and said, ‘I’ve got to take a p***’.
“I could smell alcohol on his breath. He pushed past me. He basically just pushed me out of the way.”
The PC told the court that O’Connor ran approximately 300 metres from the vehicle before he was detained by another officer at the city’s Rose Street Lane.
He was taken into custody at St Leonard’s police station and police found two bags of white powder in his possession. The powder in the bags later tested positive for cocaine.
Mr O’Donnell asked PC Eager whether she had cautioned his client under the terms of the Misuse of Drugs Act at any time during the incident.
The constable replied that she had not.
Mr O’Donnell also asked her colleague whether O’Connor was cautioned at any point.
PC Morrow also admitted that he had not and said that he and his colleague had just been “chatting” to the occupants of the Land Rover.
O’Connor denies the charges.
The trial continues.